From a3e84bd5045c141d0ec0e5fcea22ab9685ebde53 Mon Sep 17 00:00:00 2001 From: Richard Kuhnt Date: Wed, 11 Oct 2017 18:13:49 +0200 Subject: [PATCH] Remove two more abort functions and improve output (fixes #1758) --- libexec/scoop-install.ps1 | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/libexec/scoop-install.ps1 b/libexec/scoop-install.ps1 index 2f801bd4..c7881a88 100644 --- a/libexec/scoop-install.ps1 +++ b/libexec/scoop-install.ps1 @@ -32,17 +32,18 @@ reset_aliases -function ensure_not_installed($app, $global) { +function is_installed($app, $global) { if(installed $app $global) { - $global_flag = $null; - if($global){ $global_flag = ' --global' } + function gf($g) { if($g) { ' --global' } } $version = @(versions $app $global)[-1] if(!(install_info $app $version $global)) { - abort "It looks like a previous installation of $app failed.`nRun 'scoop uninstall $app$global_flag' before retrying the install." + error "It looks like a previous installation of $app failed.`nRun 'scoop uninstall $app$(gf $global)' before retrying the install." } - abort "'$app' ($version) is already installed.`nUse 'scoop update $app$global_flag' to install a new version." + warn "'$app' ($version) is already installed.`nUse 'scoop update $app$(gf $global)' to install a new version." + return $true } + return $false } $opt, $apps, $err = getopt $args 'gika:' 'global', 'independent', 'no-cache', 'arch=' @@ -64,7 +65,9 @@ if(is_scoop_outdated) { } if($apps.length -eq 1) { - ensure_not_installed $apps $global + if(is_installed $apps $global) { + return + } } # get any specific versions that we need to handle first @@ -101,7 +104,10 @@ ensure_none_failed $apps $global $apps, $skip = prune_installed $apps $global -$skip | ? { $explicit_apps -contains $_} | % { warn "$_ is already installed. Skipping." } +$skip | ? { $explicit_apps -contains $_} | % { + $version = @(versions $_ $global)[-1] + warn "'$_' ($version) is already installed. Skipping." +} $suggested = @{}; $apps | % { install_app $_ $architecture $global $suggested $use_cache }