in tool.ts [458:490]
export async function extractZip(file: string, destination?: string): Promise<string> {
if (!file) {
throw new Error("parameter 'file' is required");
}
console.log(tl.loc('TOOL_LIB_ExtractingArchive'));
let dest = _createExtractFolder(destination);
if (process.platform == 'win32') {
// build the powershell command
let escapedFile = file.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
let escapedDest = dest.replace(/'/g, "''").replace(/"|\n|\r/g, '');
let command: string = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
// change the console output code page to UTF-8.
// TODO: FIX WHICH: let chcpPath = tl.which('chcp.com', true);
let chcpPath = path.join(process.env.windir, "system32", "chcp.com");
await tl.exec(chcpPath, '65001');
// run powershell
let powershell: trm.ToolRunner = tl.tool('powershell')
.line('-NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command')
.arg(command);
await powershell.exec();
}
else {
let unzip: trm.ToolRunner = tl.tool('unzip')
.arg(file);
await unzip.exec(<trm.IExecOptions>{ cwd: dest });
}
return dest;
}