mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
Merged
This commit is contained in:
commit
df064ec4be
@ -52,7 +52,7 @@ Ensure-Exists $sourcesPath
|
||||
Ensure-Executable "7z"
|
||||
|
||||
foreach ($s in $sources) {
|
||||
Write-Host "Getting $($s.name) from URL $($s.url)"
|
||||
Write-Output "Getting $($s.name) from URL $($s.url)"
|
||||
|
||||
# We do not care about the extensions/type of archive
|
||||
$tempArchive = "$($s.name).tmp"
|
||||
@ -68,4 +68,4 @@ foreach ($s in $sources) {
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
Write-Host "All good and done!"
|
||||
Write-Verbose "All good and done!"
|
||||
|
45
scripts/utils.ps1
Normal file
45
scripts/utils.ps1
Normal file
@ -0,0 +1,45 @@
|
||||
function Ensure-Exists ($path) {
|
||||
if (-not (Test-Path $path)) {
|
||||
Write-Error "Missing required $path file"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Ensure-Executable ($command) {
|
||||
try { Get-Command $command -ErrorAction Stop > $null }
|
||||
catch {
|
||||
Write-Error "Missing $command! Ensure it is installed and on in the PATH"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Delete-Existing ($path) {
|
||||
Write-Verbose "Remove $path"
|
||||
Remove-Item -Recurse -force $path -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
function Extract-Archive ($source, $target) {
|
||||
Invoke-Expression "7z x -y -o$($target) $source"
|
||||
if ($lastexitcode -ne 0) {
|
||||
Write-Error "Extracting of $source failied"
|
||||
}
|
||||
Remove-Item $source
|
||||
}
|
||||
|
||||
function Create-Archive ($source, $target, $params) {
|
||||
$command = "7z a -x@`"$source\packignore`" $params $target $source"
|
||||
Write-Verbose "Running: $command"
|
||||
Invoke-Expression $command
|
||||
if ($lastexitcode -ne 0) {
|
||||
Write-Error "Compressing $source failied"
|
||||
}
|
||||
}
|
||||
|
||||
# If directory contains only one child directory
|
||||
# Flatten it instead
|
||||
function Flatten-Directory ($name) {
|
||||
$child = (Get-Childitem $name)[0]
|
||||
Rename-Item $name -NewName "$($name)_moving"
|
||||
Move-Item -Path "$($name)_moving\$child" -Destination $name
|
||||
Remove-Item -Recurse "$($name)_moving"
|
||||
}
|
Loading…
Reference in New Issue
Block a user