Skip to content

Commit a39ed47

Browse files
committed
Add ovveride opotion to ps version of function
1 parent 87b70b9 commit a39ed47

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Invoke-7zdec.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ param(
44
[string]$Source,
55

66
[Parameter(Mandatory = $true)]
7-
[string]$Target)
7+
[string]$Target,
8+
9+
[Parameter(Mandatory = $false)]
10+
[boolean]$OverrideDestDirectory)
811

912
# This script translates the output from 7zdec into UTF8. Node has limited
1013
# built-in support for encodings.
@@ -35,8 +38,9 @@ $writer = New-Object System.IO.StreamWriter($stdout, $utf8)
3538
Set-Location -LiteralPath $Target
3639

3740
# Print the ##command.
41+
$overrideDest = $(If ($OverrideDestDirectory) { "-aoa" } Else { "" })
3842
$_7zdec = Join-Path -Path "$PSScriptRoot" -ChildPath "externals/7zdec.exe"
39-
[System.Console]::WriteLine("##[command]$_7zdec x `"$Source`"")
43+
[System.Console]::WriteLine("##[command]$_7zdec $overrideDest x `"$Source`"")
4044

4145
# The $OutputEncoding variable instructs PowerShell how to interpret the output
4246
# from the external command.

tool.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ export async function cacheFile(sourceFile: string,
382382
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
383383
* Be sure to check the current license agreement. If 7zr.exe is bundled with your task, then the path
384384
* to 7zr.exe can be pass to this function.
385-
* @param overwriteDest Overwriting files in destination catalog. Optional.
385+
* @param overwriteDest Overwrite files in destination catalog. Optional.
386386
* @returns path to the destination directory
387387
*/
388388
export async function extract7z(file: string, dest?: string, _7zPath?: string, overwriteDest?: boolean): Promise<string> {
@@ -420,7 +420,7 @@ export async function extract7z(file: string, dest?: string, _7zPath?: string, o
420420
let escapedScript = path.join(__dirname, 'Invoke-7zdec.ps1').replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
421421
let escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
422422
let escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
423-
let command: string = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`
423+
let command: string = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}' -OverrideDestDirectory ${overwriteDest ? 1 : 0}`;
424424
let powershellPath = tl.which('powershell', true);
425425
let powershell: trm.ToolRunner = tl.tool(powershellPath)
426426
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')

0 commit comments

Comments
 (0)