make powershell scripts consistent

This commit is contained in:
David Refoua 2022-11-06 11:32:22 +03:30
parent fbe3e17eea
commit fc44def0ad
5 changed files with 24 additions and 24 deletions

View File

@ -88,7 +88,7 @@ if ($Compile) {
Pop-Location
}
if (-Not $noVendor) {
if (-not $noVendor) {
# Check for requirements
Ensure-Exists $sourcesPath
Ensure-Executable "7z"
@ -162,7 +162,7 @@ if (-Not $noVendor) {
Pop-Location
}
if (-Not $Compile -Or $noVendor) {
if (-not $Compile -or $noVendor) {
Write-Warning "You are not building the full project, Use -Compile without -noVendor"
Write-Warning "This cannot be a release. Test build only!"
return

View File

@ -55,7 +55,7 @@ function Match-Filenames {
$position = 0
if ([String]::IsNullOrEmpty($filename) -Or [String]::IsNullOrEmpty($filenameDownload)) {
if ([String]::IsNullOrEmpty($filename) -or [String]::IsNullOrEmpty($filenameDownload)) {
throw "Either one or both filenames are empty!"
}
@ -88,15 +88,15 @@ function Fetch-DownloadUrl {
$url = [uri] $urlStr
if ((-Not $url) -Or ($null -eq $url) -Or ($url -eq '')) {
if ((-not $url) -or ($null -eq $url) -or ($url -eq '')) {
throw "Failed to parse url: $urlStr"
}
if (-Not ("http", "https" -Contains $url.Scheme)) {
if (-not ("http", "https" -contains $url.Scheme)) {
throw "unknown source scheme: $($url.Scheme)"
}
if (-Not ($url.Host -ilike "*github.com")) {
if (-not ($url.Host -ilike "*github.com")) {
throw "unknown source domain: $($url.Host)"
}
@ -116,12 +116,12 @@ function Fetch-DownloadUrl {
$charCount = 0
if (-Not ($info -Is [array])) {
if (-not ($info -is [array])) {
throw "The response received from API server is invalid"
}
:loop foreach ($i in $info) {
if (-Not ($i.assets -Is [array])) {
if (-not ($i.assets -is [array])) {
continue
}
@ -157,12 +157,12 @@ function Fetch-DownloadUrl {
}
# Special case for archive downloads of repository
if (($null -eq $downloadLinks) -Or (-Not $downloadLinks)) {
if ((($p | % { $_.Trim('/') }) -Contains "archive") -And $info[0].tag_name) {
if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
if ((($p | ForEach-Object { $_.Trim('/') }) -contains "archive") -and $info[0].tag_name) {
for ($i = 0; $i -lt $p.Length; $i++) {
if ($p[$i].Trim('/') -eq "archive") {
$p[$i + 1] = $info[0].tag_name + ".zip"
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -Join '')
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '')
return $downloadLinks
}
}
@ -188,11 +188,11 @@ function Fetch-DownloadUrl {
$downloadLinks = $temp | Where-Object { (Match-Filenames $url $_ true) -eq $charCount }
if (($null -eq $downloadLinks) -Or (-Not $downloadLinks)) {
if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
throw "No suitable download links matched for the url!"
}
if (-Not($downloadLinks -is [String])) {
if (-not($downloadLinks -is [String])) {
throw "Found multiple matches for the same url:`n" + $downloadLinks
}
@ -211,7 +211,7 @@ foreach ($s in $sources) {
$downloadUrl = Fetch-DownloadUrl $s.url
if (($null -eq $downloadUrl) -Or ($downloadUrl -eq '')) {
if (($null -eq $downloadUrl) -or ($downloadUrl -eq '')) {
Write-Verbose "No new links were found"
continue
}
@ -222,15 +222,15 @@ foreach ($s in $sources) {
$version = ''
if ( ($url.Segments[-3] -eq "download/") -And ($url.Segments[-2].StartsWith("v")) ) {
if (($url.Segments[-3] -eq "download/") -and ($url.Segments[-2].StartsWith("v"))) {
$version = $url.Segments[-2].TrimStart('v').TrimEnd('/')
}
if ( ($url.Segments[-2] -eq "archive/") ) {
if (($url.Segments[-2] -eq "archive/")) {
$version = [System.IO.Path]::GetFileNameWithoutExtension($url.Segments[-1].TrimStart('v').TrimEnd('/'))
}
if ( $version -eq '' ) {
if ($version -eq '') {
throw "Unable to extract version from url string"
}
@ -255,11 +255,11 @@ if ($count -eq 0) {
return
}
if ( $Env:APPVEYOR -eq 'True' ) {
if ($Env:APPVEYOR -eq 'True') {
Add-AppveyorMessage -Message "Successfully updated $count dependencies." -Category Information
}
if ( $Env:GITHUB_ACTIONS -eq 'true' ) {
if ($Env:GITHUB_ACTIONS -eq 'true') {
Write-Output "::notice title=Task Complete::Successfully updated $count dependencies."
}

View File

@ -226,12 +226,12 @@ function Download-File {
$useBitTransfer = $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and ($PSVersionTable.PSVersion.Major -le 5)
$File = $File -Replace "/", "\"
$File = $File -replace "/", "\"
try {
if ($useBitTransfer) {
Start-BitsTransfer -Source $Url -Destination $File -DisplayName "Downloading $Url to $File"
Return
Start-BitsTransfer -Source $Url -Destination $File -DisplayName "Downloading '$Url' to $File"
return
}
}
catch {

View File

@ -1,4 +1,4 @@
if (test-path $env:temp\cmder_diag_ps.log) {
if (Test-Path $env:temp\cmder_diag_ps.log) {
remove-item $env:temp\cmder_diag_ps.log
}

View File

@ -1818,7 +1818,7 @@ function Expand-ZipModule {
# Check if powershell v3+ and .net v4.5 is available
$netFailed = $true
if ( $PSVersionTable.PSVersion.Major -ge 3 -and (Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4' -Recurse | Get-ItemProperty -Name Version | Where-Object { $_.Version -like '4.5*' -Or $_.Version -ge '4.5' }) ) {
if ( $PSVersionTable.PSVersion.Major -ge 3 -and (Get-ChildItem -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4' -Recurse | Get-ItemProperty -Name Version | Where-Object { $_.Version -like '4.5*' -or $_.Version -ge '4.5' }) ) {
Write-Debug 'Attempting unzip using the .NET Framework...'
try {