mirror of
https://github.com/cmderdev/cmder.git
synced 2025-01-26 16:19:08 +08:00
make powershell scripts consistent
This commit is contained in:
parent
fbe3e17eea
commit
fc44def0ad
@ -88,7 +88,7 @@ if ($Compile) {
|
|||||||
Pop-Location
|
Pop-Location
|
||||||
}
|
}
|
||||||
|
|
||||||
if (-Not $noVendor) {
|
if (-not $noVendor) {
|
||||||
# Check for requirements
|
# Check for requirements
|
||||||
Ensure-Exists $sourcesPath
|
Ensure-Exists $sourcesPath
|
||||||
Ensure-Executable "7z"
|
Ensure-Executable "7z"
|
||||||
@ -162,7 +162,7 @@ if (-Not $noVendor) {
|
|||||||
Pop-Location
|
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 "You are not building the full project, Use -Compile without -noVendor"
|
||||||
Write-Warning "This cannot be a release. Test build only!"
|
Write-Warning "This cannot be a release. Test build only!"
|
||||||
return
|
return
|
||||||
|
@ -55,7 +55,7 @@ function Match-Filenames {
|
|||||||
|
|
||||||
$position = 0
|
$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!"
|
throw "Either one or both filenames are empty!"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,15 +88,15 @@ function Fetch-DownloadUrl {
|
|||||||
|
|
||||||
$url = [uri] $urlStr
|
$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"
|
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)"
|
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)"
|
throw "unknown source domain: $($url.Host)"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,12 +116,12 @@ function Fetch-DownloadUrl {
|
|||||||
|
|
||||||
$charCount = 0
|
$charCount = 0
|
||||||
|
|
||||||
if (-Not ($info -Is [array])) {
|
if (-not ($info -is [array])) {
|
||||||
throw "The response received from API server is invalid"
|
throw "The response received from API server is invalid"
|
||||||
}
|
}
|
||||||
|
|
||||||
:loop foreach ($i in $info) {
|
:loop foreach ($i in $info) {
|
||||||
if (-Not ($i.assets -Is [array])) {
|
if (-not ($i.assets -is [array])) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,12 +157,12 @@ function Fetch-DownloadUrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Special case for archive downloads of repository
|
# Special case for archive downloads of repository
|
||||||
if (($null -eq $downloadLinks) -Or (-Not $downloadLinks)) {
|
if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
|
||||||
if ((($p | % { $_.Trim('/') }) -Contains "archive") -And $info[0].tag_name) {
|
if ((($p | ForEach-Object { $_.Trim('/') }) -contains "archive") -and $info[0].tag_name) {
|
||||||
for ($i = 0; $i -lt $p.Length; $i++) {
|
for ($i = 0; $i -lt $p.Length; $i++) {
|
||||||
if ($p[$i].Trim('/') -eq "archive") {
|
if ($p[$i].Trim('/') -eq "archive") {
|
||||||
$p[$i + 1] = $info[0].tag_name + ".zip"
|
$p[$i + 1] = $info[0].tag_name + ".zip"
|
||||||
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -Join '')
|
$downloadLinks = $url.Scheme + "://" + $url.Host + ($p -join '')
|
||||||
return $downloadLinks
|
return $downloadLinks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,11 +188,11 @@ function Fetch-DownloadUrl {
|
|||||||
|
|
||||||
$downloadLinks = $temp | Where-Object { (Match-Filenames $url $_ true) -eq $charCount }
|
$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!"
|
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
|
throw "Found multiple matches for the same url:`n" + $downloadLinks
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ foreach ($s in $sources) {
|
|||||||
|
|
||||||
$downloadUrl = Fetch-DownloadUrl $s.url
|
$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"
|
Write-Verbose "No new links were found"
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -222,15 +222,15 @@ foreach ($s in $sources) {
|
|||||||
|
|
||||||
$version = ''
|
$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('/')
|
$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('/'))
|
$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"
|
throw "Unable to extract version from url string"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +255,11 @@ if ($count -eq 0) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $Env:APPVEYOR -eq 'True' ) {
|
if ($Env:APPVEYOR -eq 'True') {
|
||||||
Add-AppveyorMessage -Message "Successfully updated $count dependencies." -Category Information
|
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."
|
Write-Output "::notice title=Task Complete::Successfully updated $count dependencies."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,12 +226,12 @@ function Download-File {
|
|||||||
|
|
||||||
$useBitTransfer = $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and ($PSVersionTable.PSVersion.Major -le 5)
|
$useBitTransfer = $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and ($PSVersionTable.PSVersion.Major -le 5)
|
||||||
|
|
||||||
$File = $File -Replace "/", "\"
|
$File = $File -replace "/", "\"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($useBitTransfer) {
|
if ($useBitTransfer) {
|
||||||
Start-BitsTransfer -Source $Url -Destination $File -DisplayName "Downloading $Url to $File"
|
Start-BitsTransfer -Source $Url -Destination $File -DisplayName "Downloading '$Url' to $File"
|
||||||
Return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
|
2
vendor/bin/cmder_diag.ps1
vendored
2
vendor/bin/cmder_diag.ps1
vendored
@ -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
|
remove-item $env:temp\cmder_diag_ps.log
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/psmodules/PsGet/PsGet.psm1
vendored
2
vendor/psmodules/PsGet/PsGet.psm1
vendored
@ -1818,7 +1818,7 @@ function Expand-ZipModule {
|
|||||||
|
|
||||||
# Check if powershell v3+ and .net v4.5 is available
|
# Check if powershell v3+ and .net v4.5 is available
|
||||||
$netFailed = $true
|
$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...'
|
Write-Debug 'Attempting unzip using the .NET Framework...'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user