diff --git a/CHANGELOG.md b/CHANGELOG.md index 4da0c4eef7..7efbd1ba8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## [0.6.5](https://github.com/Ash258/Scoop-Core/milestone/5) +- **format**: Always convert forward slashes into backslashes in persist property - Respect `NO_JUNCTIONS` config when resolving helper utilities - Fallback to executable from PATH when the utility is not installed via scoop. diff --git a/bin/format.ps1 b/bin/format.ps1 index 1f60115321..2b19405498 100644 --- a/bin/format.ps1 +++ b/bin/format.ps1 @@ -37,7 +37,9 @@ function _infoMes ($name, $mes) { Write-UserMessage -Message "${name}: $mes" -In function _adjustProperty ($Manifest, $Property, $ScriptBlock, [Switch] $SkipAutoupdate, [Switch] $SkipArchitecture) { $prop = $Manifest.$Property if ($prop) { - $Manifest.$Property = $ScriptBlock.Invoke($prop)[0] + $result = $ScriptBlock.Invoke($prop) + $result = if (($prop.Count -gt 1) -or ($result.Count -gt 1)) { $result } else { $result[0] } + $Manifest.$Property = $result } # Architecture specific @@ -45,10 +47,11 @@ function _adjustProperty ($Manifest, $Property, $ScriptBlock, [Switch] $SkipAuto if (!$SkipArchitecture -and $archSpec) { (Get-NotePropertyEnumerator -Object $archSpec).Name | ForEach-Object { if ($archSpec.$_ -and $archSpec.$_.$Property) { - $Manifest.architecture.$_.$Property = $ScriptBlock.Invoke($archSpec.$_.$Property) + $result = $ScriptBlock.Invoke($archSpec.$_.$Property) + $result = if (($archSpec.$_.$Property.Count -gt 1) -or ($result.Count -eq 1)) { $result } else { $result[0] } + $Manifest.architecture.$_.$Property = $result } } - } if (!$SkipAutoupdate -and $Manifest.autoupdate) { @@ -59,6 +62,22 @@ function _adjustProperty ($Manifest, $Property, $ScriptBlock, [Switch] $SkipAuto } #region Formatters +$binPersistBackslashFormatBlock = { + $new = @() + foreach ($_a in $args) { + if ($_a.Count -eq 1) { + # String + $new += $_a -replace '/', '\' + } elseif ($_a.Count -gt 1) { + # Array with 2 or more items + $_a[0] = $_a[0] -replace '/', '\' + $new += , $_a + } + } + + return $new +} + $checkverFormatBlock = { $checkver = $Manifest.checkver if ($checkver -and ($checkver.GetType() -ne [System.String])) { @@ -140,6 +159,10 @@ foreach ($gci in Get-ChildItem $Dir "$App.*" -File) { $manifest = _adjustProperty -Manifest $manifest -Property 'checkver' -ScriptBlock $checkverFormatBlock -SkipAutoupdate + # Backslash format + $manifest = _adjustProperty -Manifest $manifest -Property 'bin' -ScriptBlock $binPersistBackslashFormatBlock + $manifest = _adjustProperty -Manifest $manifest -Property 'persist' -ScriptBlock $binPersistBackslashFormatBlock + #region Architecture properties sort # TODO: Extract foreach ($mainProp in 'architecture', 'autoupdate') {