mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2026-09-23 05:46:30 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
+2
-1
@@ -1,3 +1,4 @@
|
||||
{
|
||||
"extras": "https://github.com/lukesampson/scoop-extras.git"
|
||||
"extras": "https://github.com/lukesampson/scoop-extras.git",
|
||||
"nirsoft": "https://github.com/kodybrown/scoop-nirsoft"
|
||||
}
|
||||
+18
-37
@@ -3,10 +3,10 @@
|
||||
# Help: 'scoop update' updates Scoop to the latest version.
|
||||
# 'scoop update <app>' installs a new version of that app, if there is one.
|
||||
#
|
||||
# You can use '*' in place of <app> to update all apps.
|
||||
#
|
||||
# Options:
|
||||
# --local, -l update a locally installed app (default)
|
||||
# --global, -g update a globally installed app
|
||||
# --all, -a updates all installed apps (use -l or -g to limit)
|
||||
. "$psscriptroot\..\lib\core.ps1"
|
||||
. "$psscriptroot\..\lib\install.ps1"
|
||||
. "$psscriptroot\..\lib\decompress.ps1"
|
||||
@@ -17,11 +17,9 @@
|
||||
. "$psscriptroot\..\lib\depends.ps1"
|
||||
. "$psscriptroot\..\lib\config.ps1"
|
||||
|
||||
$opt, $apps, $err = getopt $args 'lga' 'local','global','all'
|
||||
$opt, $apps, $err = getopt $args 'g' 'global'
|
||||
if($err) { "scoop update: $err"; exit 1 }
|
||||
$global = $opt.g -or $opt.global
|
||||
$all = $opt.all
|
||||
$local = $opt.l -or $opt.local
|
||||
|
||||
function update_scoop() {
|
||||
$tempdir = versiondir 'scoop' 'update'
|
||||
@@ -135,38 +133,12 @@ function ensure_all_installed($apps, $global) {
|
||||
}
|
||||
}
|
||||
|
||||
function update_all() {
|
||||
# Get the list of apps
|
||||
$localapps = @()
|
||||
if($local -or !($global)) {
|
||||
$localapps = installed_apps $false | % { @{ name = $_ } }
|
||||
}
|
||||
$globalapps = @()
|
||||
if(!($local) -and $global) {
|
||||
$globalapps = installed_apps $true | % { @{ name = $_; global = $true } }
|
||||
}
|
||||
|
||||
$apps = @($localapps) + @($globalapps)
|
||||
|
||||
# For each app, call update(--$app--, $global)
|
||||
if($apps) {
|
||||
$apps | % { update $_.name $_.global }
|
||||
""
|
||||
} else {
|
||||
if($local -and !($global)) {
|
||||
$x = "local "
|
||||
} elseif ($global) {
|
||||
$x = "global "
|
||||
} else {
|
||||
$x = ""
|
||||
}
|
||||
"there aren't any $($x)apps installed"
|
||||
}
|
||||
# convert list of apps to list of ($app, $global) tuples
|
||||
function applist($apps, $global) {
|
||||
return ,@($apps |% { ,@($_, $global) })
|
||||
}
|
||||
|
||||
if($all) {
|
||||
update_all
|
||||
} elseif(!$apps) {
|
||||
if(!$apps) {
|
||||
if($global) {
|
||||
"scoop update: --global is invalid when <app> not specified"; exit 1
|
||||
}
|
||||
@@ -176,9 +148,18 @@ if($all) {
|
||||
'ERROR: you need admin rights to update global apps'; exit 1
|
||||
}
|
||||
|
||||
ensure_all_installed $apps $global
|
||||
if($apps -eq '*') {
|
||||
$apps = applist (installed_apps $false) $false
|
||||
if($global) {
|
||||
$apps += applist (installed_apps $true) $true
|
||||
}
|
||||
} else {
|
||||
ensure_all_installed $apps $global
|
||||
$apps = applist $apps $global
|
||||
}
|
||||
|
||||
$apps | % { update $_ $global }
|
||||
# $apps is now a list of ($app, $global) tuples
|
||||
$apps | % { update @_ }
|
||||
}
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user