add common helpers

This commit is contained in:
Dmitry Shibanov
2020-05-29 15:24:03 +03:00
parent 7c335a2ccc
commit 00f276c05e
18 changed files with 548 additions and 175 deletions

View File

@@ -20,13 +20,25 @@ function Create-TarArchive {
[String]$SourceFolder,
[Parameter(Mandatory=$true)]
[String]$ArchivePath,
[string]$CompressionType = "gz"
[string]$CompressionType = "gz",
[switch]$DereferenceSymlinks
)
$CompressionTypeArgument = If ([string]::IsNullOrWhiteSpace($CompressionType)) { "" } else { "--${CompressionType}" }
$arguments = @(
"-c",
"-f", $ArchivePath,
"."
)
If ($CompressionType) {
$arguments += "--${CompressionType}"
}
if ($DereferenceSymlinks) {
$arguments += "-h"
}
Push-Location $SourceFolder
Write-Debug "tar -c $CompressionTypeArgument -f $ArchivePath ."
tar -c $CompressionTypeArgument -f $ArchivePath .
Write-Debug "tar $arguments"
tar @arguments
Pop-Location
}