Skip to content

Commit c44e214

Browse files
authored
feat(config): Support portable config file (#5369)
1 parent 7c6aeb2 commit c44e214

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Features
44

55
- **scoop-update:** Add support for parallel syncing buckets in PowerShell 7 and improve output ([#5122](https://github.com/ScoopInstaller/Scoop/issues/5122))
6+
- **config:** Support portable config file ([#5369](https://github.com/ScoopInstaller/Scoop/issues/5369))
67

78
### Bug Fixes
89

lib/core.ps1

+23
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,29 @@ Optimize-SecurityProtocol
12971297
# Load Scoop config
12981298
$configHome = $env:XDG_CONFIG_HOME, "$env:USERPROFILE\.config" | Select-Object -First 1
12991299
$configFile = "$configHome\scoop\config.json"
1300+
# Check if it's the expected install path for scoop: <root>/apps/scoop/current
1301+
$coreRoot = Split-Path $PSScriptRoot
1302+
$pathExpected = ($coreRoot -replace '\\','/') -like '*apps/scoop/current*'
1303+
if ($pathExpected) {
1304+
# Portable config is located in root directory:
1305+
# .\current\scoop\apps\<root>\config.json <- a reversed path
1306+
# Imagine `<root>/apps/scoop/current/` in a reversed format,
1307+
# and the directory tree:
1308+
#
1309+
# ```
1310+
# <root>:
1311+
# ├─apps
1312+
# ├─buckets
1313+
# ├─cache
1314+
# ├─persist
1315+
# ├─shims
1316+
# ├─config.json
1317+
# ```
1318+
$configPortablePath = fullpath "$coreRoot\..\..\..\config.json"
1319+
if (Test-Path $configPortablePath) {
1320+
$configFile = $configPortablePath
1321+
}
1322+
}
13001323
$scoopConfig = load_cfg $configFile
13011324

13021325
# NOTE Scoop config file migration. Remove this after 2023/6/30

0 commit comments

Comments
 (0)