feat: Added pre-commit hook of PowerShell scrip checker

This commit is contained in:
Jakub Kocka
2024-04-30 12:36:00 +02:00
parent aa27fbd231
commit 8f383060dd
7 changed files with 45 additions and 17 deletions

View File

@@ -26,10 +26,10 @@ foreach ($line in $envars_raw) {
$envars_array += (, ($var_name, $var_val))
}
if ($IsWindows -eq $null) {
if ($null -eq $IsWindows) {
# $IsWindows was added in PowerShell Core 6 and PowerShell 7 together with multi-platform support. # I.E. if this
# internal variable is not set then PowerShell 5 is used and # the platform cannot be # anything else than Windows.
$IsWindows = $true
$Windows = $true
}
foreach ($pair in $envars_array) {
@@ -38,7 +38,7 @@ foreach ($pair in $envars_array) {
$var_val = $pair[1].Trim() # trim spaces on the ends of the val
if ($var_name -eq "PATH") {
# trim "%PATH%" or "`$PATH"
if ($IsWindows) {
if ($IsWindows || $Windows) {
$var_val = $var_val.Trim($S + "%PATH%")
} else {
$var_val = $var_val.Trim($S + "`$PATH")
@@ -60,7 +60,7 @@ function parttool.py { &python "$IDF_PATH\components\partition_table\parttool.py
#Compare Path's OLD vs. NEW
$NEW_PATH = $env:PATH.split($S) | Select-Object -Unique # array without duplicates
$dif_Path = Compare-Object -ReferenceObject $OLD_PATH -DifferenceObject $NEW_PATH -PassThru
if ($dif_Path -ne $null) {
if ($null -ne $dif_Path) {
Write-Output "`nAdded to PATH`n-------------"
Write-Output $dif_Path
} else {