Skip to content

Commit 18710c1

Browse files
author
Tatyana Kostromskaya (Akvelon)
committed
Merge branch 'master' into users/tatyana-kostromskaya/downloadtool-logging
2 parents e5c65b6 + 426ba81 commit 18710c1

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
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.

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "azure-pipelines-tool-lib",
3-
"version": "1.2.1",
3+
"version": "1.3.1",
44
"description": "Azure Pipelines Tool Installer Lib for CI/CD Tasks",
55
"main": "tool.js",
66
"scripts": {

tool.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,10 @@ export async function cacheFile(sourceFile: string,
434434
* time of this writing, it is freely available from the LZMA SDK that is available on the 7zip website.
435435
* Be sure to check the current license agreement. If 7zr.exe is bundled with your task, then the path
436436
* to 7zr.exe can be pass to this function.
437+
* @param overwriteDest Overwrite files in destination catalog. Optional.
437438
* @returns path to the destination directory
438439
*/
439-
export async function extract7z(file: string, dest?: string, _7zPath?: string): Promise<string> {
440+
export async function extract7z(file: string, dest?: string, _7zPath?: string, overwriteDest?: boolean): Promise<string> {
440441
if (process.platform != 'win32') {
441442
throw new Error('extract7z() not supported on current OS');
442443
}
@@ -454,20 +455,25 @@ export async function extract7z(file: string, dest?: string, _7zPath?: string):
454455

455456
if (_7zPath) {
456457
// extract
457-
let _7z: trm.ToolRunner = tl.tool(_7zPath)
458-
.arg('x') // eXtract files with full paths
459-
.arg('-bb1') // -bb[0-3] : set output log level
460-
.arg('-bd') // disable progress indicator
461-
.arg('-sccUTF-8') // set charset for for console input/output
462-
.arg(file);
458+
const _7z: trm.ToolRunner = tl.tool(_7zPath);
459+
if (overwriteDest) {
460+
_7z.arg('-aoa');
461+
}
462+
463+
_7z.arg('x') // eXtract files with full paths
464+
.arg('-bb1') // -bb[0-3] : set output log level
465+
.arg('-bd') // disable progress indicator
466+
.arg('-sccUTF-8') // set charset for for console input/output
467+
.arg(file);
463468
await _7z.exec();
464469
}
465470
else {
466471
// extract
467472
let escapedScript = path.join(__dirname, 'Invoke-7zdec.ps1').replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
468473
let escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, '');
469474
let escapedTarget = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
470-
let command: string = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}'`
475+
const overrideDestDirectory: number = overwriteDest ? 1 : 0;
476+
const command: string = `& '${escapedScript}' -Source '${escapedFile}' -Target '${escapedTarget}' -OverrideDestDirectory ${overrideDestDirectory}`;
471477
let powershellPath = tl.which('powershell', true);
472478
let powershell: trm.ToolRunner = tl.tool(powershellPath)
473479
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')

0 commit comments

Comments
 (0)