Skip to content

Commit 37aa459

Browse files
committed
Read and parse schema.json once
1 parent d9f07a3 commit 37aa459

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

lib/json.ps1

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,16 @@ function Sort-ScoopManifestRootProperties {
222222
)
223223

224224
# Get wanted order from Scoop manifest schema
225-
Write-Debug -Message ('{0}\..\schema.json' -f $PSScriptRoot)
226-
$WantedOrder = [string[]](
227-
(
228-
parse_json -path (
229-
'{0}\..\schema.json' -f $PSScriptRoot
230-
)
231-
).'properties'.'PSObject'.'Properties'.'Name'
232-
)
225+
if ([string]::IsNullOrWhiteSpace($Script:WantedOrder)) {
226+
Write-Debug -Message ('{0}\..\schema.json' -f $PSScriptRoot)
227+
$Script:WantedOrder = [string[]](
228+
(
229+
parse_json -path (
230+
'{0}\..\schema.json' -f $PSScriptRoot
231+
)
232+
).'properties'.'PSObject'.'Properties'.'Name'
233+
)
234+
}
233235

234236
# Create empty new object where properties will be added to
235237
$SortedObject = [PSCustomObject]::new()

0 commit comments

Comments
 (0)