3131 }
3232}
3333
34- Run git checkout main
35- Run git pull
36-
37- # 2. Retrieve the date-time to create a unique branch name.
34+ Invoke-NativeCommand git checkout main
35+ Invoke-NativeCommand git pull
3836$timeStamp = Get-Date - Format ' yyyyMMdd-HHmmss'
3937$branchName = " auto-font-update-$timeStamp "
38+ Invoke-NativeCommand git checkout - b $branchName
4039
41- # 3. Create a new branch for the changes.
42- Run git checkout - b $branchName
43-
44- # 4. Retrieve the latest font data from Nerd Fonts.
4540$release = Get-GitHubRelease - Owner ryanoasis - Repository nerd- fonts
4641$fonts = @ ()
4742$fontAssets = $release | Get-GitHubReleaseAsset | Where-Object { $_.Name -like ' *.zip' }
@@ -53,29 +48,22 @@ foreach ($fontArchive in $fontAssets) {
5348 }
5449}
5550
56- $fonts | Sort-Object Name | Format-Table - AutoSize | Out-String
51+ LogGroup ' Latest Fonts' {
52+ $fonts | Sort-Object Name | Format-Table - AutoSize | Out-String
53+ }
5754
58- # 5. Write results to FontsData.json.
5955$parentFolder = Split-Path - Path $PSScriptRoot - Parent
6056$filePath = Join-Path - Path $parentFolder - ChildPath ' src\FontsData.json'
61-
62- # Make sure file exists (or overwrite).
6357$null = New-Item - Path $filePath - ItemType File - Force
6458$fonts | ConvertTo-Json | Set-Content - Path $filePath - Force
6559
66- # 6. Check if anything actually changed.
67- # If git status --porcelain is empty, there are no new changes to commit.
68- $changes = Run git status -- porcelain
69-
70-
60+ $changes = Invoke-NativeCommand git status -- porcelain
7161if (-not [string ]::IsNullOrWhiteSpace($changes )) {
72- # 7. Commit and push changes.
73- Run git add .
74- Run git commit - m " Update-FontsData via script on $timeStamp "
75- Run git push -- set-upstream origin $branchName
62+ Invoke-NativeCommand git add .
63+ Invoke-NativeCommand git commit - m " Update-FontsData via script on $timeStamp "
64+ Invoke-NativeCommand git push -- set-upstream origin $branchName
7665
77- # 8. Create a PR via GitHub CLI.
78- Run gh pr create `
66+ Invoke-NativeCommand gh pr create `
7967 -- base main `
8068 -- head $branchName `
8169 -- title " Auto-Update: NerdFonts Data ($timeStamp )" `
0 commit comments