Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
29 changes: 26 additions & 3 deletions bin/format.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,21 @@ 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
$archSpec = $Manifest.architecture
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) {
Expand All @@ -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])) {
Expand Down Expand Up @@ -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') {
Expand Down