Skip to content
This repository was archived by the owner on Oct 30, 2025. It is now read-only.

Commit 16d6471

Browse files
committed
fix: Adopt shovel commands automatically
Extraction 3 of #1
1 parent 8e3ac8d commit 16d6471

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

install.ps1

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
.LINK
5151
https://scoop.sh
5252
.LINK
53-
https://github.com/lukesampson/scoop/wiki
53+
https://github.com/ScoopInstaller/Scoop/wiki
5454
#>
5555
param(
5656
[String] $ScoopDir,
@@ -258,6 +258,7 @@ function Import-ScoopShim {
258258
}
259259

260260
# The scoop shim
261+
# TODO: Switch
261262
$shim = "$SCOOP_SHIMS_DIR\scoop"
262263

263264
# Convert to relative path
@@ -284,6 +285,10 @@ powershell -noprofile -ex unrestricted `"& '$path' %args%;exit `$lastexitcode`""
284285

285286
# Make scoop accessible from bash or other posix shell
286287
Write-Output "#!/bin/sh`npowershell.exe -ex unrestricted `"$path`" `"$@`"" | Out-File $shim -Encoding 'ascii'
288+
289+
# Adopt shovel commands
290+
Get-ChildItem $SCOOP_SHIMS_DIR -Filter 'scoop.*' |
291+
Copy-Item -Destination { Join-Path $_.Directory.FullName (($_.BaseName -replace 'scoop', 'shovel') + $_.Extension) }
287292
}
288293

289294
function Get-Env {
@@ -305,7 +310,7 @@ function Add-ShimsDirToPath {
305310
if (!$h.EndsWith('\')) { $h += '\' }
306311

307312
if ($h -ne '\') {
308-
$friendlyPath = "$SCOOP_SHIMS_DIR" -replace ([Regex]::Escape($h)), '~\'
313+
$friendlyPath = $SCOOP_SHIMS_DIR -replace ([Regex]::Escape($h)), '~\'
309314
Write-InstallInfo "Adding $friendlyPath to your path."
310315
} else {
311316
Write-InstallInfo "Adding $SCOOP_SHIMS_DIR to your path."
@@ -393,7 +398,7 @@ function Add-DefaultConfig {
393398
if ((Test-IsAdministrator) -and $env:SCOOP_CACHE) {
394399
[Environment]::SetEnvironmentVariable('SCOOP_CACHE', $env:SCOOP_CACHE, 'Machine')
395400
} else {
396-
if ($SCOOP_CACHE_DIR -ne "$SCOOP_DIR\cache") {
401+
if ($SCOOP_CACHE_DIR -ne $SCOOP_CACHE_DEFAULT_DIR) {
397402
Add-Config -Name 'cachePath' -Value $SCOOP_CACHE_DIR | Out-Null
398403
}
399404
}
@@ -471,20 +476,29 @@ if (!$env:USERPROFILE) {
471476
# Prepare variables
472477
$IS_EXECUTED_FROM_IEX = ($null -eq $MyInvocation.MyCommand.Path)
473478

479+
$SCOOP_DEFAULT_DIR = "${env:USERPROFILE}\scoop"
480+
$SCOOP_GLOBAL_DEFAULT_DIR = "${env:ProgramData}\scoop"
481+
$SCOOP_CACHE_DEFAULT_DIR = "${SCOOP_DEFAULT_DIR}\cache"
482+
483+
# TODO: Change and rebrand
474484
# Scoop root directory
475-
$SCOOP_DIR = $ScoopDir, $env:SCOOP, "${env:USERPROFILE}\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
485+
$SCOOP_DIR = $ScoopDir, $env:SCOOP, $SCOOP_DEFAULT_DIR | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
476486
# Scoop global apps directory
477-
$SCOOP_GLOBAL_DIR = $ScoopGlobalDir, $env:SCOOP_GLOBAL, "${env:ProgramData}\scoop" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
487+
$SCOOP_GLOBAL_DIR = $ScoopGlobalDir, $env:SCOOP_GLOBAL, $SCOOP_GLOBAL_DEFAULT_DIR | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
478488
# Scoop cache directory
479-
$SCOOP_CACHE_DIR = $ScoopCacheDir, $env:SCOOP_CACHE, "${SCOOP_DIR}\cache" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
489+
$SCOOP_CACHE_DIR = $ScoopCacheDir, $env:SCOOP_CACHE, $SCOOP_CACHE_DEFAULT_DIR | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
480490
# Scoop shims directory
481491
$SCOOP_SHIMS_DIR = "${SCOOP_DIR}\shims"
492+
# Scoop global shims directory
493+
$SCOOP_GLOBAL_SHIMS_DIR = "${SCOOP_GLOBAL_DIR}\shims"
482494
# Scoop itself directory
483495
$SCOOP_APP_DIR = "${SCOOP_DIR}\apps\scoop\current"
496+
# Scoop buckets directory
497+
$SCOOP_BUCKETS_DIR = "${SCOOP_DIR}\buckets"
484498
# Scoop main bucket directory
485499
$SCOOP_MAIN_BUCKET_DIR = "${SCOOP_DIR}\buckets\main"
486500
# Scoop config file location
487-
$SCOOP_CONFIG_HOME = $env:XDG_CONFIG_HOME, "${env:USERPROFILE}\.config" | Select-Object -First 1
501+
$SCOOP_CONFIG_HOME = $env:XDG_CONFIG_HOME, "${env:USERPROFILE}\.config" | Where-Object { -not [String]::IsNullOrEmpty($_) } | Select-Object -First 1
488502
$SCOOP_CONFIG_FILE = "${SCOOP_CONFIG_HOME}\scoop\config.json"
489503

490504
# TODO: Use a specific version of Scoop and the main bucket

0 commit comments

Comments
 (0)