Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #79 from paulbouwer/76-installation-error-null-path
Browse files Browse the repository at this point in the history
Issue #76 - Error shown during installation when PATH is null
  • Loading branch information
paulbouwer committed Dec 13, 2015
2 parents c6228ff + 47eb85d commit 884e20d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions install/installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ function Write-ErrorMessage
Write-Host $("{0}" -f " $message ") -BackgroundColor DarkRed -ForegroundColor White
}

function String-IsEmptyOrWhitespace
{
param (
[string] $str
)
return [string]::IsNullOrEmpty($str) -or $str.Trim().length -eq 0
}

function New-SvmInstallLocation
{
param (
Expand Down Expand Up @@ -105,14 +113,17 @@ function Configure-Environment
$foldersToPrependToPath = @()
$foldersToPrependToPath += [System.IO.Path]::Combine($installPath, 'bin')
$foldersToPrependToPath += [System.IO.Path]::Combine($installPath, 'shims')

$newPath = ($foldersToPrependToPath)
foreach($path in $envPath.Split(';'))

if (!$(String-IsEmptyOrWhitespace( $envPath )))
{
if (!$foldersToPrependToPath.Contains($path)) { $newPath += $path }
foreach($path in $envPath.Split(';'))
{
if (!$foldersToPrependToPath.Contains($path)) { $newPath += $path }
}
}
$path = [String]::Join(';', $newPath)

# set user path
[Environment]::SetEnvironmentVariable("Path", $path, [System.EnvironmentVariableTarget]::User)
}
Expand Down

0 comments on commit 884e20d

Please sign in to comment.