Skip to content

Commit

Permalink
Use tar tool for .tar.gz (#1050)
Browse files Browse the repository at this point in the history
  • Loading branch information
KonstantinTyukalov authored Aug 6, 2024
1 parent a783d8a commit b36e97f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions node/buildutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const getExternalsAsync = async () => {
downloadFileAsync(nodeUrl + '/' + nodeVersion + '/win-x64/node.exe'),
downloadFileAsync(nodeUrl + '/' + nodeVersion + '/win-x64/node.lib')
]);

var nodeDirectory = path.join(testPath, 'node');
mkdir('-p', nodeDirectory);
cp(nodeExePath, path.join(nodeDirectory, 'node.exe'));
Expand Down Expand Up @@ -118,7 +118,7 @@ var downloadArchiveAsync = async function (url, fileName) {
if (test('-f', marker)) {
return targetPath;
}

// download the archive
var archivePath = await downloadFileAsync(url, scrubbedUrl);
console.log('Extracting archive: ' + url);
Expand All @@ -130,8 +130,16 @@ var downloadArchiveAsync = async function (url, fileName) {

// extract
mkdir('-p', targetPath);
var zip = new admZip(archivePath);
zip.extractAllTo(targetPath);

if (targetPath.endsWith('.zip')) {
var zip = new admZip(archivePath);
zip.extractAllTo(targetPath);
}
else if (targetPath.endsWith('.tar.gz')) {
run(`tar --extract --gzip --file="${archivePath}" --directory="${targetPath}"`);
} else {
throw new Error('Unsupported archive type: ' + targetPath);
}

// write the completed marker
fs.writeFileSync(marker, '');
Expand Down

0 comments on commit b36e97f

Please sign in to comment.