Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch(decompress): Allow other args to be passthrough #3411

Merged
merged 1 commit into from
Apr 29, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions lib/decompress.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,29 @@ function Expand-7ZipArchive {
[Parameter(Position = 1)]
[String]
$DestinationPath = (Split-Path $Path),
[ValidateSet("All", "Skip", "Rename")]
[String]
$Overwrite,
[Parameter(ValueFromRemainingArguments = $true)]
[String]
$Switches,
[Switch]
$Removal
)
$LogLocation = "$(Split-Path $Path)\7zip.log"
switch ($Overwrite) {
"All" { $Switches += " -aoa" }
"Skip" { $Switches += " -aos" }
"Rename" { $Switches += " -aou" }
}
if ((get_config 7ZIPEXTRACT_USE_EXTERNAL)) {
try {
7z x "$Path" -o"$DestinationPath" -y | Out-File $LogLocation
7z x "$Path" -o"$DestinationPath" (-split $Switches) -y | Out-File $LogLocation
} catch [System.Management.Automation.CommandNotFoundException] {
abort "Cannot find external 7Zip (7z.exe) while '7ZIPEXTRACT_USE_EXTERNAL' is 'true'!`nRun 'scoop config 7ZIPEXTRACT_USE_EXTERNAL false' or install 7Zip manually and try again."
}
} else {
&(file_path 7zip 7z.exe) x "$Path" -o"$DestinationPath" -y | Out-File $LogLocation
&(file_path 7zip 7z.exe) x "$Path" -o"$DestinationPath" (-split $Switches) -y | Out-File $LogLocation
}
if ($LASTEXITCODE -ne 0) {
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)"
Expand Down Expand Up @@ -125,11 +136,14 @@ function Expand-InnoArchive {
[Parameter(Position = 1)]
[String]
$DestinationPath = (Split-Path $Path),
[Parameter(ValueFromRemainingArguments = $true)]
[String]
$Switches,
[Switch]
$Removal
)
$LogLocation = "$(Split-Path $Path)\innounp.log"
&(file_path innounp innounp.exe) -x -d"$DestinationPath" -c'{app}' "$Path" -y | Out-File $LogLocation
&(file_path innounp innounp.exe) -x -d"$DestinationPath" -c'{app}' "$Path" (-split $Switches) -y | Out-File $LogLocation
if ($LASTEXITCODE -ne 0) {
abort "Failed to extract files from $Path.`nLog file:`n $(friendly_path $LogLocation)"
}
Expand Down Expand Up @@ -189,7 +203,7 @@ function Expand-ZipArchive {

function extract_7zip($path, $to, $removal) {
Show-DeprecatedWarning $MyInvocation 'Expand-7ZipArchive'
Expand-7ZipArchive -Path $path -DestinationPath $to -Removal:$removal
Expand-7ZipArchive -Path $path -DestinationPath $to -Removal:$removal @args
}

function extract_msi($path, $to, $removal) {
Expand All @@ -199,7 +213,7 @@ function extract_msi($path, $to, $removal) {

function unpack_inno($path, $to, $removal) {
Show-DeprecatedWarning $MyInvocation 'Expand-InnoArchive'
Expand-InnoArchive -Path $path -DestinationPath $to -Removal:$removal
Expand-InnoArchive -Path $path -DestinationPath $to -Removal:$removal @args
}

function extract_zip($path, $to, $removal) {
Expand Down