Enable specifying extraction destination
This commit is contained in:
parent
af49565b85
commit
be26fe61b5
6 changed files with 29 additions and 24 deletions
15
lib/tar.js
generated
15
lib/tar.js
generated
|
|
@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.isZstdAvailable = isZstdAvailable;
|
||||
exports.extract = extract;
|
||||
exports.extractTarZst = extractTarZst;
|
||||
exports.createExtractFolder = createExtractFolder;
|
||||
exports.inferCompressionMethod = inferCompressionMethod;
|
||||
const child_process_1 = require("child_process");
|
||||
const fs = __importStar(require("fs"));
|
||||
|
|
@ -109,22 +110,23 @@ async function extract(tarPath, compressionMethod, tarVersion, logger) {
|
|||
// Defensively continue to call the toolcache API as requesting a gzipped
|
||||
// bundle may be a fallback option.
|
||||
return await toolcache.extractTar(tarPath);
|
||||
case "zstd":
|
||||
case "zstd": {
|
||||
if (!tarVersion) {
|
||||
throw new Error("Could not determine tar version, which is required to extract a Zstandard archive.");
|
||||
}
|
||||
return await extractTarZst(tarPath, tarVersion, logger);
|
||||
const dest = await createExtractFolder();
|
||||
await extractTarZst(tarPath, dest, tarVersion, logger);
|
||||
return dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Extract a compressed tar archive
|
||||
*
|
||||
* @param tar tar stream, or path to the tar
|
||||
* @param dest destination directory. Optional.
|
||||
* @returns path to the destination directory
|
||||
* @param dest destination directory
|
||||
*/
|
||||
async function extractTarZst(tar, tarVersion, logger) {
|
||||
const dest = await createExtractFolder();
|
||||
async function extractTarZst(tar, dest, tarVersion, logger) {
|
||||
logger.debug(`Extracting to ${dest}.${tar instanceof stream.Readable
|
||||
? ` Input stream has high water mark ${tar.readableHighWaterMark}.`
|
||||
: ""}`);
|
||||
|
|
@ -161,7 +163,6 @@ async function extractTarZst(tar, tarVersion, logger) {
|
|||
resolve();
|
||||
});
|
||||
});
|
||||
return dest;
|
||||
}
|
||||
catch (e) {
|
||||
await (0, util_1.cleanUpGlob)(dest, "extraction destination directory", logger);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue