mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
Updated build and pack Powershell
This commit is contained in:
parent
b0b8eaef1e
commit
e1c60104ba
@ -27,6 +27,7 @@
|
||||
.LINK
|
||||
https://github.com/bliker/cmder - Project Home
|
||||
#>
|
||||
|
||||
[CmdletBinding(SupportsShouldProcess=$true)]
|
||||
Param(
|
||||
# CmdletBinding will give us;
|
||||
@ -34,58 +35,22 @@ Param(
|
||||
# -whatif switch to not actually make changes
|
||||
|
||||
# Path to the vendor configuration source file
|
||||
[string]$sourcesPath = "..\vendor\sources.json"
|
||||
[string]$sourcesPath = "..\vendor\sources.json",
|
||||
|
||||
, # Vendor folder locaton
|
||||
# Vendor folder locaton
|
||||
[string]$saveTo = "..\vendor\"
|
||||
)
|
||||
|
||||
function Ensure-Exists ($item) {
|
||||
if (-not (Test-Path $item)) {
|
||||
Write-Error "Missing required $item 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
|
||||
}
|
||||
|
||||
# Check for archives that were not extracted correctly
|
||||
# when the folder contains another folder
|
||||
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"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
. "$PSScriptRoot\utils.ps1"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Push-Location -Path $saveTo
|
||||
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json
|
||||
|
||||
# Check for requirements
|
||||
Ensure-Exists $sourcesPath
|
||||
Ensure-Executable "7z"
|
||||
|
||||
Push-Location -Path $saveTo
|
||||
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json
|
||||
|
||||
foreach ($s in $sources) {
|
||||
Write-Host "Getting $($s.name) from URL $($s.url)"
|
||||
|
||||
@ -100,8 +65,7 @@ foreach ($s in $sources) {
|
||||
if ((Get-Childitem $s.name).Count -eq 1) {
|
||||
Flatten-Directory($s.name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Pop-Location
|
||||
Write-Host "All good and done!"
|
||||
Write-Host "All good and done!"
|
@ -0,0 +1,52 @@
|
||||
<#
|
||||
.Synopsis
|
||||
Pack cmder
|
||||
.DESCRIPTION
|
||||
Use this script to pack cmder into release archives
|
||||
|
||||
You will need to make this script executable by setting your Powershell Execution Policy to Remote signed
|
||||
Then unblock the script for execution with UnblockFile .\pack.ps1
|
||||
.EXAMPLE
|
||||
.\pack.ps1
|
||||
|
||||
Creates default archives for cmder
|
||||
.EXAMPLE
|
||||
.\build -verbose
|
||||
|
||||
Creates default archives for cmder with plenty of information
|
||||
.NOTES
|
||||
AUTHORS
|
||||
Samuel Vasko, Jack Bennett
|
||||
Part of the Cmder project.
|
||||
.LINK
|
||||
https://github.com/bliker/cmder - Project Home
|
||||
#>
|
||||
|
||||
[CmdletBinding(SupportsShouldProcess=$true)]
|
||||
Param(
|
||||
# CmdletBinding will give us;
|
||||
# -verbose switch to turn on logging and
|
||||
# -whatif switch to not actually make changes
|
||||
|
||||
# Path to the vendor configuration source file
|
||||
[string]$cmderRoot = "..",
|
||||
|
||||
# Vendor folder locaton
|
||||
[string]$saveTo = "."
|
||||
)
|
||||
|
||||
. "$PSScriptRoot\utils.ps1"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$targets = @{
|
||||
"cmder.zip" = $null;
|
||||
"cmder.7z" = $null;
|
||||
"cmder_mini.zip" = "-x!`"..\vendor\msysgit`"";
|
||||
}
|
||||
|
||||
$version = Invoke-Expression "git describe --abbrev=0 --tags"
|
||||
New-Item -ItemType file "$cmderRoot\Version $version"
|
||||
|
||||
foreach ($t in $targets.GetEnumerator()) {
|
||||
Create-Archive $cmderRoot "$saveTo\$($t.Name)" $t.Value
|
||||
}
|
Loading…
Reference in New Issue
Block a user