Skip to content

Commit

Permalink
Add-Path([string]$item,[switch]$before)
Browse files Browse the repository at this point in the history
  • Loading branch information
FeodorFitsner committed Oct 12, 2019
1 parent beea225 commit cfe1491
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/path-utils.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
([Environment]::GetEnvironmentVariable("path", "machine")).Split(";") | Sort-Object
}

function Add-Path([string]$item)
function Add-Path([string]$item,[switch]$before)
{
$item = (Get-SanitizedPath $item)
$pathItemsArray = ([Environment]::GetEnvironmentVariable("path", "machine")).Split(";")
Expand All @@ -21,7 +21,11 @@ function Add-Path([string]$item)

if($index -eq -1) {
# item not found - add it
$pathItems.Add($item) | Out-null
if ($before) {
$pathItems.Insert(0, $item)
} else {
$pathItems.Add($item) | Out-null
}

# update PATH variable
$updatedPath = $pathItems -join ';'
Expand Down

0 comments on commit cfe1491

Please sign in to comment.