mirror of
https://github.com/ScoopInstaller/Scoop.git
synced 2025-10-30 06:07:56 +00:00
perf(scoop): Load libs only once (#4839)
This commit is contained in:
@@ -69,9 +69,9 @@ param(
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\..\lib\core.ps1"
|
||||
. "$PSScriptRoot\..\lib\autoupdate.ps1"
|
||||
. "$PSScriptRoot\..\lib\manifest.ps1"
|
||||
. "$PSScriptRoot\..\lib\buckets.ps1"
|
||||
. "$PSScriptRoot\..\lib\autoupdate.ps1"
|
||||
. "$PSScriptRoot\..\lib\json.ps1"
|
||||
. "$PSScriptRoot\..\lib\versions.ps1"
|
||||
. "$PSScriptRoot\..\lib\install.ps1" # needed for hash generation
|
||||
@@ -105,7 +105,7 @@ Get-Event | ForEach-Object {
|
||||
$Queue | ForEach-Object {
|
||||
$name, $json = $_
|
||||
|
||||
$substitutions = Get-VersionSubstitution $json.version
|
||||
$substitutions = Get-VersionSubstitution $json.version # 'autoupdate.ps1'
|
||||
|
||||
$wc = New-Object Net.Webclient
|
||||
if ($json.checkver.useragent) {
|
||||
@@ -337,7 +337,7 @@ while ($in_progress -gt 0) {
|
||||
Write-Host 'Forcing autoupdate!' -ForegroundColor DarkMagenta
|
||||
}
|
||||
try {
|
||||
Invoke-AutoUpdate $App $Dir $json $ver $matchesHashtable
|
||||
Invoke-AutoUpdate $App $Dir $json $ver $matchesHashtable # 'autoupdate.ps1'
|
||||
} catch {
|
||||
if ($ThrowError) {
|
||||
throw $_
|
||||
|
||||
@@ -1,32 +1,56 @@
|
||||
#Requires -Version 5
|
||||
param($cmd)
|
||||
param($SubCommand)
|
||||
|
||||
Set-StrictMode -off
|
||||
Set-StrictMode -Off
|
||||
|
||||
. "$PSScriptRoot\..\lib\core.ps1"
|
||||
. "$PSScriptRoot\..\lib\buckets.ps1"
|
||||
. "$PSScriptRoot\..\lib\commands.ps1"
|
||||
. "$PSScriptRoot\..\lib\help.ps1"
|
||||
|
||||
# for aliases where there's a local function, re-alias so the function takes precedence
|
||||
$aliases = Get-Alias | Where-Object { $_.Options -notmatch 'ReadOnly|AllScope' } | ForEach-Object { $_.Name }
|
||||
Get-ChildItem Function: | Where-Object -Property Name -In -Value $aliases | ForEach-Object {
|
||||
Set-Alias -Name $_.Name -Value Local:$($_.Name) -Scope Script
|
||||
}
|
||||
|
||||
$commands = commands
|
||||
if ('--version' -contains $cmd -or (!$cmd -and '-v' -contains $args)) {
|
||||
Write-Host "Current Scoop version:"
|
||||
Invoke-Expression "git -C '$(versiondir 'scoop' 'current')' --no-pager log --oneline HEAD -n 1"
|
||||
Write-Host ""
|
||||
|
||||
Get-LocalBucket | ForEach-Object {
|
||||
$bucketLoc = Find-BucketDirectory $_ -Root
|
||||
if(Test-Path (Join-Path $bucketLoc '.git')) {
|
||||
Write-Host "'$_' bucket:"
|
||||
Invoke-Expression "git -C '$bucketLoc' --no-pager log --oneline HEAD -n 1"
|
||||
Write-Host ""
|
||||
switch ($SubCommand) {
|
||||
({ $SubCommand -in @($null, '--help', '/?') }) {
|
||||
if (!$SubCommand -and $Args -eq '-v') {
|
||||
$SubCommand = '--version'
|
||||
} else {
|
||||
exec 'help'
|
||||
}
|
||||
}
|
||||
({ $SubCommand -eq '--version' }) {
|
||||
Write-Host 'Current Scoop version:'
|
||||
if ((Test-CommandAvailable git) -and (Test-Path "$PSScriptRoot\..\.git") -and (get_config SCOOP_BRANCH 'master') -ne 'master') {
|
||||
Invoke-Expression "git -C '$PSScriptRoot\..' --no-pager log --oneline HEAD -n 1"
|
||||
} else {
|
||||
$version = Select-String -Pattern '^## \[(v[\d.]+)\].*?([\d-]+)$' -Path "$PSScriptRoot\..\CHANGELOG.md"
|
||||
Write-Host $version.Matches.Groups[1].Value -ForegroundColor Cyan -NoNewline
|
||||
Write-Host " - Released at $($version.Matches.Groups[2].Value)"
|
||||
}
|
||||
Write-Host ''
|
||||
|
||||
Get-LocalBucket | ForEach-Object {
|
||||
$bucketLoc = Find-BucketDirectory $_ -Root
|
||||
if ((Test-Path (Join-Path $bucketLoc '.git')) -and (Test-CommandAvailable git)) {
|
||||
Write-Host "'$_' bucket:"
|
||||
Invoke-Expression "git -C '$bucketLoc' --no-pager log --oneline HEAD -n 1"
|
||||
Write-Host ''
|
||||
}
|
||||
}
|
||||
}
|
||||
({ $SubCommand -in (commands) }) {
|
||||
if ($Args -in @('-h', '--help', '/?')) {
|
||||
exec 'help' @($SubCommand)
|
||||
} else {
|
||||
exec $SubCommand $Args
|
||||
}
|
||||
}
|
||||
default {
|
||||
"scoop: '$SubCommand' isn't a scoop command. See 'scoop help'."
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
elseif (@($null, '--help', '/?') -contains $cmd -or $args[0] -contains '-h') { exec 'help' $args }
|
||||
elseif ($commands -contains $cmd) { exec $cmd $args }
|
||||
else { "scoop: '$cmd' isn't a scoop command. See 'scoop help'."; exit 1 }
|
||||
|
||||
Reference in New Issue
Block a user