Skip to content

Commit f9a092e

Browse files
committed
fix: Skip migration if '$scoopConfig' is NULL
Signed-off-by: Hsiao-nan Cheung <niheaven@gmail.com>
1 parent e4f8799 commit f9a092e

File tree

1 file changed

+22
-20
lines changed

1 file changed

+22
-20
lines changed

lib/core.ps1

+22-20
Original file line numberDiff line numberDiff line change
@@ -1205,26 +1205,28 @@ $configFile = "$configHome\scoop\config.json"
12051205
$scoopConfig = load_cfg $configFile
12061206

12071207
# NOTE Scoop config file migration. Remove this after 2023/6/30
1208-
$newConfigNames = @{
1209-
'lastupdate' = 'last_update'
1210-
'SCOOP_REPO' = 'scoop_repo'
1211-
'SCOOP_BRANCH' = 'scoop_branch'
1212-
'7ZIPEXTRACT_USE_EXTERNAL' = 'use_external_7zip'
1213-
'MSIEXTRACT_USE_LESSMSI' = 'use_lessmsi'
1214-
'NO_JUNCTIONS' = 'no_junction'
1215-
'manifest_review' = 'show_manifest'
1216-
'rootPath' = 'root_path'
1217-
'globalPath' = 'global_path'
1218-
'cachePath' = 'cache_path'
1219-
}
1220-
$newConfigNames.GetEnumerator() | ForEach-Object {
1221-
if ($null -ne $scoopConfig.$($_.Key)) {
1222-
$value = $scoopConfig.$($_.Key)
1223-
$scoopConfig.PSObject.Properties.Remove($_.Key)
1224-
$scoopConfig | Add-Member -MemberType NoteProperty -Name $_.Value -Value $value
1225-
}
1226-
}
1227-
ConvertTo-Json $scoopConfig | Out-UTF8File -FilePath $configFile
1208+
if ($scoopConfig) {
1209+
$newConfigNames = @{
1210+
'lastupdate' = 'last_update'
1211+
'SCOOP_REPO' = 'scoop_repo'
1212+
'SCOOP_BRANCH' = 'scoop_branch'
1213+
'7ZIPEXTRACT_USE_EXTERNAL' = 'use_external_7zip'
1214+
'MSIEXTRACT_USE_LESSMSI' = 'use_lessmsi'
1215+
'NO_JUNCTIONS' = 'no_junction'
1216+
'manifest_review' = 'show_manifest'
1217+
'rootPath' = 'root_path'
1218+
'globalPath' = 'global_path'
1219+
'cachePath' = 'cache_path'
1220+
}
1221+
$newConfigNames.GetEnumerator() | ForEach-Object {
1222+
if ($null -ne $scoopConfig.$($_.Key)) {
1223+
$value = $scoopConfig.$($_.Key)
1224+
$scoopConfig.PSObject.Properties.Remove($_.Key)
1225+
$scoopConfig | Add-Member -MemberType NoteProperty -Name $_.Value -Value $value
1226+
}
1227+
}
1228+
ConvertTo-Json $scoopConfig | Out-UTF8File -FilePath $configFile
1229+
}
12281230
# END NOTE
12291231

12301232
# Scoop root directory

0 commit comments

Comments
 (0)