Skip to content

Commit

Permalink
change unzip logic
Browse files Browse the repository at this point in the history
  • Loading branch information
satbai authored and ericsciple committed Aug 7, 2018
1 parent 950d4a7 commit 1071669
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
12 changes: 9 additions & 3 deletions make-util.js
@@ -1,4 +1,3 @@
var admZip = require('adm-zip');
var check = require('validator');
var fs = require('fs');
var makeOptions = require('./make-options.json');
Expand Down Expand Up @@ -433,8 +432,15 @@ var downloadArchive = function (url, omitExtensionCheck) {
// extract
mkdir('-p', targetPath);
if (isZip) {
var zip = new admZip(archivePath);
zip.extractAllTo(targetPath);
if (process.platform == 'win32') {
let escapedFile = archivePath.replace(/'/g, "''").replace(/"|\n|\r/g, ''); // double-up single quotes, remove double quotes and newlines
let escapedDest = targetPath.replace(/'/g, "''").replace(/"|\n|\r/g, '');

let command = `$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; [System.IO.Compression.ZipFile]::ExtractToDirectory('${escapedFile}', '${escapedDest}')`;
run(`powershell -Command "${command}"`);
} else {
run(`unzip ${archivePath} -d ${targetPath}`);
}
}
else if (isTargz) {
var originalCwd = process.cwd();
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -28,7 +28,6 @@
},
"homepage": "https://github.com/Microsoft/vsts-tasks",
"devDependencies": {
"adm-zip": "0.4.7",
"gulp": "3.9.0",
"gulp-util": "3.0.4",
"markdown-toc": "^1.2.0",
Expand Down

0 comments on commit 1071669

Please sign in to comment.