From ff3cd3e77b344acfbf22e27cad74b60783bbfff0 Mon Sep 17 00:00:00 2001 From: Luke Sampson Date: Sat, 15 Jun 2013 14:25:14 +1000 Subject: [PATCH] uninstall: remove scoop from path add sublime project with settings to use windows line endings by default --- .gitignore | 3 ++- bucket/runat.json | 5 +++++ install.ps1 | 2 +- lib/init.ps1 | 6 +++++- scoop.sublime-project | 11 +++++++++++ uninstall.ps1 | 17 +++++++++++------ 6 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 bucket/runat.json create mode 100644 scoop.sublime-project diff --git a/.gitignore b/.gitignore index 90c63c5e6..988752815 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store -._.DS_Store \ No newline at end of file +._.DS_Store +scoop.sublime-workspace \ No newline at end of file diff --git a/bucket/runat.json b/bucket/runat.json new file mode 100644 index 000000000..1cfb40a44 --- /dev/null +++ b/bucket/runat.json @@ -0,0 +1,5 @@ +{ + "name": "runat", + "url": "https://gist.github.com/lukesampson/5778559/raw/runat.ps1", + "version": 0.1 +} \ No newline at end of file diff --git a/install.ps1 b/install.ps1 index ad060ea0c..c4bac130d 100644 --- a/install.ps1 +++ b/install.ps1 @@ -26,5 +26,5 @@ echo 'creating stub...' stub "$abs_appdir\scoop-master\scoop.ps1" ensure_scoop_in_path -success 'you successfully installed scoop!' +success 'scoop was successfully installed!' echo 'type "scoop help" for instructions' diff --git a/lib/init.ps1 b/lib/init.ps1 index 667d16165..3397c7900 100644 --- a/lib/init.ps1 +++ b/lib/init.ps1 @@ -12,6 +12,9 @@ function success($msg) { write-host $msg -b green -f black; } function appdir($name) { "$scoopdir\apps\$name" } function fname($path) { split-path $path -leaf } function ensure($dir) { if(!(test-path $dir)) { mkdir $dir > $null }; resolve-path $dir } +function full_path($path) { + $executionContext.sessionState.path.getUnresolvedProviderPathFromPSPath($path) +} function friendly_path($path) { return "$path" -replace ([regex]::escape($home)), "~" } @@ -24,6 +27,7 @@ function unzip($path,$to) { $zipfiles = $shell.namespace("$path").items() $shell.namespace("$to").copyHere($zipFiles, 4) # 4 = don't show progress dialog } +function coalesce($a, $b) { if($a) { return $a } $b } function stub($path) { if(!(test-path $path)) { abort "can't stub $(fname $path): couldn't find $path"} @@ -39,7 +43,7 @@ function ensure_scoop_in_path { $abs_bindir = ensure $bindir if($userpath -notmatch [regex]::escape($abs_bindir)) { # be aggressive (b-e-aggressive) and install scoop first in the path - echo "adding $(friendly_path $abs_bindir) to your user path" + echo "adding $(friendly_path $abs_bindir) to your path" env 'path' "$abs_bindir;$userpath" # for future sessions $env:path = "$abs_bindir;$env:path" # for this session } diff --git a/scoop.sublime-project b/scoop.sublime-project new file mode 100644 index 000000000..36582826d --- /dev/null +++ b/scoop.sublime-project @@ -0,0 +1,11 @@ +{ + "folders": + [ + { + "path": "." + } + ], + "settings": { + "default_line_ending": "windows" + } +} diff --git a/uninstall.ps1 b/uninstall.ps1 index 2de9d11f8..1ccbee536 100644 --- a/uninstall.ps1 +++ b/uninstall.ps1 @@ -1,12 +1,17 @@ . .\lib\init.ps1 if(test-path $scoopdir) { - rm -r $scoopdir -} else { - echo "couldn't find $(friendly_path $scoopdir)" + try { + rm -r $scoopdir -ea stop + } catch { + abort "couldn't remove $(friendly_path $scoopdir): it may be in use" + } } +$bindir_regex = [regex]::escape((full_path $bindir)) +if((env 'path') -match $bindir_regex) { # future sessions + echo "removing $(friendly_path $bindir) from your path" + env 'path' ((env 'path') -replace $bindir_regex, '') +} -# todo: remove scoop\bin from path - -success "you successfully uninstalled scoop" \ No newline at end of file +success "scoop has been uninstalled" \ No newline at end of file