added path resolve to add-workspace
This commit is contained in:
parent
bb2ab60ac1
commit
9f08b09c21
|
@ -47,13 +47,26 @@ function Add-Workspace {
|
|||
[Parameter(Mandatory=$false)]
|
||||
[string]$Path)
|
||||
|
||||
# If no path was provided -- get the cwd
|
||||
# NOTE: This is not a test for whether the path exists, just
|
||||
# a test about whether the argument was provided.
|
||||
if(-Not $Path) {
|
||||
$Path = Get-Location
|
||||
}
|
||||
|
||||
if(Test-Path -Path $Path) {
|
||||
if(-Not (Test-Path -Path $Path)) {
|
||||
Write-Output "$Path does not exist, cannot create workspace"
|
||||
return
|
||||
}
|
||||
|
||||
# Now we know we have a path that exist. However it
|
||||
# might be a relative path, so resolve to the full path.
|
||||
$resolvedPath = Resolve-Path $Path
|
||||
Write-Output "using resolved path: $resolvedPath"
|
||||
|
||||
if(Test-Path -Path $resolvedPath) {
|
||||
$workspaceSettings = Test-Workspace-Settings
|
||||
$workspaceEntry = "{0},{1}" -f $Name, $Path
|
||||
$workspaceEntry = "{0},{1}" -f $Name, $resolvedPath
|
||||
if($workspaceSettings) {
|
||||
if(Test-Workspace-Alias -Alias $Name) {
|
||||
Write-Host "Alias already exists: $Name"
|
||||
|
@ -69,9 +82,6 @@ function Add-Workspace {
|
|||
Show-Workspace-Settings
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Output "$Path does not exist, cannot create workspace"
|
||||
}
|
||||
}
|
||||
|
||||
# Set the active workspace using workspace alias
|
||||
|
|
Loading…
Reference in New Issue
Block a user