Skip to content

Commit

Permalink
fix: Skip migration if '$scoopConfig' is NULL
Browse files Browse the repository at this point in the history
Signed-off-by: Hsiao-nan Cheung <niheaven@gmail.com>
  • Loading branch information
niheaven committed Aug 20, 2022
1 parent e4f8799 commit f9a092e
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions lib/core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1205,26 +1205,28 @@ $configFile = "$configHome\scoop\config.json"
$scoopConfig = load_cfg $configFile

# NOTE Scoop config file migration. Remove this after 2023/6/30
$newConfigNames = @{
'lastupdate' = 'last_update'
'SCOOP_REPO' = 'scoop_repo'
'SCOOP_BRANCH' = 'scoop_branch'
'7ZIPEXTRACT_USE_EXTERNAL' = 'use_external_7zip'
'MSIEXTRACT_USE_LESSMSI' = 'use_lessmsi'
'NO_JUNCTIONS' = 'no_junction'
'manifest_review' = 'show_manifest'
'rootPath' = 'root_path'
'globalPath' = 'global_path'
'cachePath' = 'cache_path'
}
$newConfigNames.GetEnumerator() | ForEach-Object {
if ($null -ne $scoopConfig.$($_.Key)) {
$value = $scoopConfig.$($_.Key)
$scoopConfig.PSObject.Properties.Remove($_.Key)
$scoopConfig | Add-Member -MemberType NoteProperty -Name $_.Value -Value $value
}
}
ConvertTo-Json $scoopConfig | Out-UTF8File -FilePath $configFile
if ($scoopConfig) {
$newConfigNames = @{
'lastupdate' = 'last_update'
'SCOOP_REPO' = 'scoop_repo'
'SCOOP_BRANCH' = 'scoop_branch'
'7ZIPEXTRACT_USE_EXTERNAL' = 'use_external_7zip'
'MSIEXTRACT_USE_LESSMSI' = 'use_lessmsi'
'NO_JUNCTIONS' = 'no_junction'
'manifest_review' = 'show_manifest'
'rootPath' = 'root_path'
'globalPath' = 'global_path'
'cachePath' = 'cache_path'
}
$newConfigNames.GetEnumerator() | ForEach-Object {
if ($null -ne $scoopConfig.$($_.Key)) {
$value = $scoopConfig.$($_.Key)
$scoopConfig.PSObject.Properties.Remove($_.Key)
$scoopConfig | Add-Member -MemberType NoteProperty -Name $_.Value -Value $value
}
}
ConvertTo-Json $scoopConfig | Out-UTF8File -FilePath $configFile
}
# END NOTE

# Scoop root directory
Expand Down

0 comments on commit f9a092e

Please # to comment.