diff --git a/CHANGELOG.md b/CHANGELOG.md index 138e330708..053607ce7a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Features - **scoop-update:** Add support for parallel syncing buckets in PowerShell 7 and improve output ([#5122](https://github.com/ScoopInstaller/Scoop/issues/5122)) +- **config:** Support portable config file ([#5369](https://github.com/ScoopInstaller/Scoop/issues/5369)) ### Bug Fixes diff --git a/lib/core.ps1 b/lib/core.ps1 index 3d10baf22d..d64011cf03 100644 --- a/lib/core.ps1 +++ b/lib/core.ps1 @@ -1300,6 +1300,29 @@ Optimize-SecurityProtocol # Load Scoop config $configHome = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1 $configFile = "$configHome\scoop\config.json" +# Check if it's the expected install path for scoop: /apps/scoop/current +$coreRoot = Split-Path $PSScriptRoot +$pathExpected = ($coreRoot -replace '\\','/') -like '*apps/scoop/current*' +if ($pathExpected) { + # Portable config is located in root directory: + # .\current\scoop\apps\\config.json <- a reversed path + # Imagine `/apps/scoop/current/` in a reversed format, + # and the directory tree: + # + # ``` + # : + # ├─apps + # ├─buckets + # ├─cache + # ├─persist + # ├─shims + # ├─config.json + # ``` + $configPortablePath = fullpath "$coreRoot\..\..\..\config.json" + if (Test-Path $configPortablePath) { + $configFile = $configPortablePath + } +} $scoopConfig = load_cfg $configFile # NOTE Scoop config file migration. Remove this after 2023/6/30