diff --git a/images.CI/lint-shebang.ps1 b/images.CI/shebang-linter.ps1 similarity index 72% rename from images.CI/lint-shebang.ps1 rename to images.CI/shebang-linter.ps1 index 233ed3344..f031f4a64 100644 --- a/images.CI/lint-shebang.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -7,16 +7,16 @@ function Validate-Scripts { [Parameter(Mandatory=$true)] [string]$ExpectedShebang ) - $ScriptWithoutShebangLine = @() - Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object { - $shebangLine = Get-Content -Path $($_.FullName) | Select-Object -First 1 - if ($shebangLine -eq $ExpectedShebang) { + $ScriptWithoutShebangLine = @() + Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object { + $shebangLine = Get-Content -Path $($_.FullName) | Select-Object -First 1 + if ($shebangLine -eq $ExpectedShebang) { Write-Host "Pattern '$ExpectedShebang' found in '$($_.FullName)'" - } - else { + } + else { Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'" $ScriptWithoutShebangLine += $($_.FullName) - } + } } return $ScriptWithoutShebangLine } @@ -24,13 +24,11 @@ function Validate-Scripts { $PathUbuntu = "./images/linux/scripts" $PathMacOS = "./images/macos/provision" $ScriptsWithBrokenShebang = @() -# Check Ubuntu contains required shebang string $ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -Pattern "#!/bin/bash -e" -# Check MacOS contains required shebang string $ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -Pattern "#!/bin/bash -e -o pipefail" if ($ScriptsWithBrokenShebang.Length -gt 0) { $ScriptsWithBrokenShebang | ForEach-Object { Write-Warning "The following script does not contain shebang: '$_'" - } + } exit 1 } \ No newline at end of file