Skip to content

Commit

Permalink
rename scoop/shim to scoop/shims, remove_from_path handles current se…
Browse files Browse the repository at this point in the history
…ssion as well
  • Loading branch information
lukesampson committed Jun 27, 2013
1 parent ce48687 commit c7b0425
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions bin/uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ installed_apps | % {

echo "uninstalling $app"
run_uninstaller $manifest $architecture $dir
rm_user_path $manifest $dir
}

if(test-path $scoopdir) {
Expand Down
20 changes: 14 additions & 6 deletions lib/core.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$scoopdir = "~\appdata\local\scoop"
$shimdir = "$scoopdir\shim"
$shimdir = "$scoopdir\shims"
$cachedir = "$scoopdir\cache"

# helper functions
Expand Down Expand Up @@ -97,19 +97,27 @@ function ensure_in_path($dir,$first=$false) {
}
}

function strip_path($orig_path, $dir) {
$stripped = [string]::join(';', @( $orig_path.split(';') | ? { $_ -and $_ -ne $dir } ))
return ($stripped -ne $orig_path), $stripped
}

function remove_from_path($dir) {
$dir = full_path $dir
$old = env 'path'
$new = [string]::join(';', @( $old.split(';') | ? { $_ -and $_ -ne $dir } ))

if($new -ne $old) { # future sessions only
# future sessions
$was_in_path, $newpath = strip_path (env 'path') $dir
if($was_in_path) {
echo "removing $(friendly_path $dir) from your path"
env 'path' $new
env 'path' $newpath
}

# current session
$was_in_path, $newpath = strip_path $env:path $dir
if($was_in_path) { $env:path = $newpath }
}

function ensure_scoop_in_path {
$userpath = env 'path'
$abs_shimdir = ensure $shimdir
# be aggressive (b-e-aggressive) and install scoop first in the path
ensure_in_path $abs_shimdir $true
Expand Down

0 comments on commit c7b0425

Please sign in to comment.