Skip to content

Commit

Permalink
Simplify 'application.json' Json Prefix Addition in 'Compile.ps1' Script
Browse files Browse the repository at this point in the history
Thanks to  @fam007e for improving this section in his PR ChrisTitusTech#2587 changes

Co-authored-by: fam007e <faisalmoshiur@gmail.com>
  • Loading branch information
og-mrk and fam007e committed Aug 24, 2024
1 parent 46564a3 commit 88b3d2a
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions Compile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,14 @@ Get-ChildItem "$workingdir\functions" -Recurse -File | ForEach-Object {
}
Update-Progress "Adding: Config *.json" 40
Get-ChildItem "$workingdir\config" | Where-Object {$psitem.extension -eq ".json"} | ForEach-Object {

$json = (Get-Content $psitem.FullName).replace("'","''")

# Make an Array List containing every name at first level of Json File
$jsonAsObject = $json | convertfrom-json
$firstLevelJsonList = [System.Collections.ArrayList]::new()
$jsonAsObject.PSObject.Properties.Name | ForEach-Object {$null = $firstLevelJsonList.Add($_)}

# Add 'WPFInstall' as a prefix to every entry-name in 'applications.json' file
if ($psitem.Name -eq "applications.json") {
for ($i = 0; $i -lt $firstLevelJsonList.Count; $i += 1) {
$appEntryName = $firstLevelJsonList[$i]
foreach ($appEntryName in $jsonAsObject.PSObject.Properties.Name) {
$appEntryContent = $jsonAsObject.$appEntryName
# Remove the entire app entry, so we could add it later with a different name
$jsonAsObject.PSObject.Properties.Remove($appEntryName)
# Add the app entry, but with a different name (WPFInstall + The App Entry Name)
$jsonAsObject | Add-Member -MemberType NoteProperty -Name "WPFInstall$appEntryName" -Value $appEntryContent
}
}
Expand Down

0 comments on commit 88b3d2a

Please sign in to comment.