fix(发布): 兼容 Windows 中文路径打包
This commit is contained in:
parent
a484eb9e0d
commit
94a5e8a639
@ -45,6 +45,19 @@ function Get-CommandPath([string]$name) {
|
||||
return $cmd.Source
|
||||
}
|
||||
|
||||
function Get-TarCommandPath {
|
||||
$gitCommand = Get-Command "git" -ErrorAction SilentlyContinue
|
||||
if ($gitCommand) {
|
||||
$gitRoot = Split-Path (Split-Path $gitCommand.Source -Parent) -Parent
|
||||
$gitTar = Join-Path $gitRoot "usr\bin\tar.exe"
|
||||
if (Test-Path -LiteralPath $gitTar -PathType Leaf) {
|
||||
return $gitTar
|
||||
}
|
||||
}
|
||||
|
||||
return Get-CommandPath "tar"
|
||||
}
|
||||
|
||||
function Invoke-External {
|
||||
param(
|
||||
[string]$FilePath,
|
||||
@ -199,7 +212,9 @@ if ($HostName -notmatch '^[A-Za-z0-9.:-]+$') {
|
||||
throw "Host name contains unsupported characters."
|
||||
}
|
||||
|
||||
$tarExe = Get-CommandPath "tar"
|
||||
$tarExe = Get-TarCommandPath
|
||||
$tarDirectory = Split-Path $tarExe -Parent
|
||||
$useGnuTar = Test-Path -LiteralPath (Join-Path $tarDirectory "gzip.exe") -PathType Leaf
|
||||
$remoteTarget = "$User@$HostName"
|
||||
$remoteDirLiteral = ConvertTo-ShellLiteral $RemoteDir
|
||||
$remoteArchiveLiteral = ConvertTo-ShellLiteral $RemoteArchive
|
||||
@ -299,9 +314,9 @@ $deployCommand = $deployCommand.Replace("__SKIP_DEPLOY__", $skipDeployValue)
|
||||
$deployCommand = $deployCommand.Replace("__SKIP_BACKUP__", $skipBackupValue)
|
||||
|
||||
try {
|
||||
[System.IO.File]::WriteAllLines(
|
||||
[System.IO.File]::WriteAllText(
|
||||
$fileListPath,
|
||||
[string[]]$files,
|
||||
(($files -join "`n") + "`n"),
|
||||
$utf8NoBom
|
||||
)
|
||||
|
||||
@ -310,7 +325,17 @@ try {
|
||||
}
|
||||
|
||||
Write-Host ">>> Creating release archive..."
|
||||
Invoke-External -FilePath $tarExe -Arguments @("-czf", $archivePath, "-T", $fileListPath) -Description "Create release archive"
|
||||
$tarArguments = @("-czf", $archivePath, "-T", $fileListPath)
|
||||
$originalPath = $env:PATH
|
||||
if ($useGnuTar) {
|
||||
$env:PATH = "$tarDirectory;$env:PATH"
|
||||
$tarArguments = @("--force-local") + $tarArguments
|
||||
}
|
||||
try {
|
||||
Invoke-External -FilePath $tarExe -Arguments $tarArguments -Description "Create release archive"
|
||||
} finally {
|
||||
$env:PATH = $originalPath
|
||||
}
|
||||
|
||||
if ($password) {
|
||||
$plinkExe = Get-CommandPath "plink"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user