diff --git a/bin/install.ps1 b/bin/install.ps1 index 4cad5d015..f114f6304 100644 --- a/bin/install.ps1 +++ b/bin/install.ps1 @@ -32,18 +32,6 @@ rm $zipfile echo 'creating shim...' shim "$dir\bin\scoop.ps1" $false -if(!(test-path ~/.bashrc)) { - 'creating ~/.bashrc' - new-item -type file ~/.bashrc | out-null -} -if (!(get-content ~/.bashrc | select-string 'alias scoop' -quiet)) { - 'creating bash alias for scoop...' - 'alias scoop="powershell scoop.ps1"' | out-file ~/.bashrc -en oem -append -} -else { - 'bash alias for scoop already exists... skipping...' -} - ensure_scoop_in_path success 'scoop was installed successfully!' echo "type 'scoop help' for instructions" diff --git a/libexec/scoop-reset.ps1 b/libexec/scoop-reset.ps1 index 74b896060..35a073d36 100644 --- a/libexec/scoop-reset.ps1 +++ b/libexec/scoop-reset.ps1 @@ -13,31 +13,14 @@ param($app) if(!$app) { 'ERROR: missing'; my_usage; exit 1 } -if ($app -eq "scoop") { - "resetting scoop" +if(!(installed $app)) { abort "$app isn't installed" } - if(!(test-path ~/.bashrc)) { - 'creating ~/.bashrc' - new-item -type file ~/.bashrc | out-null - } - if (!(get-content ~/.bashrc | select-string 'alias scoop' -quiet)) { - 'creating bash alias for scoop...' - 'alias scoop="powershell scoop.ps1"' | out-file ~/.bashrc -en oem -append - } - else { - 'bash alias for scoop already exists... skipping...' - } -} -else { - if(!(installed $app)) { abort "$app isn't installed" } +$version = current_version $app +"resetting $app ($version)" - $version = current_version $app - "resetting $app ($version)" +$dir = resolve-path (versiondir $app $version) +$manifest = installed_manifest $app $version - $dir = resolve-path (versiondir $app $version) - $manifest = installed_manifest $app $version - - create_shims $manifest $dir $false - env_add_path $manifest $dir - env_set $manifest $dir -} \ No newline at end of file +create_shims $manifest $dir $false +env_add_path $manifest $dir +env_set $manifest $dir \ No newline at end of file diff --git a/test/Scoop-Reset.Tests.ps1 b/test/Scoop-Reset.Tests.ps1 deleted file mode 100644 index e20ff43c6..000000000 --- a/test/Scoop-Reset.Tests.ps1 +++ /dev/null @@ -1,70 +0,0 @@ -set-alias scoop "$psscriptroot/../bin/scoop.ps1" - -describe "'scoop reset scoop'" { - beforeall { - remove-item "~/.bashrc.scoop" -ea ignore - } - - function alias_count { - (gc "~/.bashrc" | where { $_ -eq 'alias scoop="powershell scoop.ps1"' } | measure).count - } - - function backup_bashrc_if_exists { - # back up .bashrc if it exists - if(test-path "~/.bashrc") { - move-item "~/.bashrc" "~/.bashrc.scoop" - } - } - - function restore_bashrc_if_exists { - # restore backup - if(test-path "~/.bashrc.scoop") { - move-item "~/.bashrc.scoop" "~/.bashrc" - - "~/.bashrc.scoop" | should not exist - "~/.bashrc" | should exist - } - } - - context "no .bashrc" { - it "creates .bashrc when it doesn't exist" { - backup_bashrc_if_exists - - "~/.bashrc" | should not exist - scoop reset scoop - "~/.bashrc" | should exist - alias_count | should be 1 - - # cleanup - remove-item "~/.bashrc" - - restore_bashrc_if_exists - } - } - - context "bash scoop alias exists" { - it "does not create another bash scoop alias" { - # call it once to create it if it doesn't exist - scoop reset scoop - alias_count | should be 1 - - scoop reset scoop - alias_count | should be 1 - } - } - - context "bash scoop alias doesn't exist" { - it "creates bash scoop alias" { - backup_bashrc_if_exists - new-item -type file "~/.bashrc" - - alias_count | should be 0 - - scoop reset scoop - alias_count | should be 1 - - remove-item "~/.bashrc" - restore_bashrc_if_exists - } - } -} \ No newline at end of file