From 9d17a2f4cb7c14500ae6d86ec07cc1174ce5b2d0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 Aug 2025 03:02:05 +0000 Subject: [PATCH] Fix PowerShell script inconsistencies and documentation errors Co-authored-by: DRSDavidSoft <4673812+DRSDavidSoft@users.noreply.github.com> --- scripts/build.ps1 | 4 ++-- scripts/pack.ps1 | 16 ++++++++-------- scripts/update.ps1 | 10 +++++----- scripts/utils.ps1 | 6 ++---- 4 files changed, 17 insertions(+), 19 deletions(-) diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 640bba1..f87021a 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -21,7 +21,7 @@ Skip all downloads and only build launcher. .EXAMPLE - .\build -verbose + .\build.ps1 -verbose Execute the build and see what's going on. .EXAMPLE @@ -33,7 +33,7 @@ Samuel Vasko, Jack Bennett Part of the Cmder project. .LINK - http://cmder.app/ - Project Home + https://github.com/cmderdev/cmder - Project Home #> [CmdletBinding(SupportsShouldProcess = $true)] Param( diff --git a/scripts/pack.ps1 b/scripts/pack.ps1 index 418fdcd..6cf6822 100644 --- a/scripts/pack.ps1 +++ b/scripts/pack.ps1 @@ -35,7 +35,7 @@ Param( [string]$saveTo = "$PSScriptRoot\..\build" ) -$cmderRoot = Resolve-Path $cmderRoot +$cmder_root = Resolve-Path $cmderRoot . "$PSScriptRoot\utils.ps1" $ErrorActionPreference = "Stop" @@ -47,10 +47,10 @@ $targets = @{ "cmder_mini.zip" = "-xr!`"vendor\git-for-windows`""; } -Push-Location -Path $cmderRoot +Push-Location -Path $cmder_root -Delete-Existing "$cmderRoot\Version*" -Delete-Existing "$cmderRoot\build\*" +Delete-Existing "$cmder_root\Version*" +Delete-Existing "$cmder_root\build\*" if (-not (Test-Path -PathType container $saveTo)) { (New-Item -ItemType Directory -Path $saveTo) | Out-Null @@ -59,16 +59,16 @@ if (-not (Test-Path -PathType container $saveTo)) { $saveTo = Resolve-Path $saveTo $version = Get-VersionStr -(New-Item -ItemType file "$cmderRoot\Version $version") | Out-Null +(New-Item -ItemType file "$cmder_root\Version $version") | Out-Null if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) { Write-Verbose "Packing Cmder $version in $saveTo..." - $excluded = (Get-Content -Path "$cmderRoot\packignore") -Split [System.Environment]::NewLine | Where-Object { $_ } - Get-ChildItem $cmderRoot -Force -Exclude $excluded + $excluded = (Get-Content -Path "$cmder_root\packignore") -Split [System.Environment]::NewLine | Where-Object { $_ } + Get-ChildItem $cmder_root -Force -Exclude $excluded } foreach ($t in $targets.GetEnumerator()) { - Create-Archive "$cmderRoot" "$saveTo\$($t.Name)" $t.Value + Create-Archive "$cmder_root" "$saveTo\$($t.Name)" $t.Value $hash = (Digest-Hash "$saveTo\$($t.Name)") Add-Content -path "$saveTo\hashes.txt" -value ($t.Name + ' ' + $hash) } diff --git a/scripts/update.ps1 b/scripts/update.ps1 index 768744a..8c889c8 100644 --- a/scripts/update.ps1 +++ b/scripts/update.ps1 @@ -5,17 +5,17 @@ This script updates dependencies to the latest version in vendor/sources.json file. You will need to make this script executable by setting your Powershell Execution Policy to Remote signed - Then unblock the script for execution with UnblockFile .\build.ps1 + Then unblock the script for execution with UnblockFile .\update.ps1 .EXAMPLE - .\build.ps1 + .\update.ps1 Updates the dependency sources in the default location, the vendor/sources.json file. .EXAMPLE - .\build -verbose + .\update.ps1 -verbose Updates the dependency sources and see what's going on. .EXAMPLE - .\build.ps1 -SourcesPath '~/custom/vendors.json' + .\update.ps1 -SourcesPath '~/custom/vendors.json' Specify the path to update dependency sources file at. .NOTES @@ -23,7 +23,7 @@ David Refoua Part of the Cmder project. .LINK - http://cmder.app/ - Project Home + https://github.com/cmderdev/cmder - Project Home #> [CmdletBinding(SupportsShouldProcess = $true)] Param( diff --git a/scripts/utils.ps1 b/scripts/utils.ps1 index 2b81a70..87eb912 100644 --- a/scripts/utils.ps1 +++ b/scripts/utils.ps1 @@ -1,7 +1,6 @@ function Ensure-Exists($path) { if (-not (Test-Path $path)) { - Write-Error "Missing required $path! Ensure it is installed" - exit 1 + throw "Missing required $path! Ensure it is installed" } return $true > $null } @@ -16,8 +15,7 @@ function Ensure-Executable($command) { Set-Alias -Name "7z" -Value "$env:programw6432\7-zip\7z.exe" -Scope script } else { - Write-Error "Missing $command! Ensure it is installed and on in the PATH" - exit 1 + throw "Missing $command! Ensure it is installed and on in the PATH" } } }