Bundle install: Only use stdin for streaming
This commit is contained in:
parent
b35b023d9b
commit
8c3a732e36
3 changed files with 16 additions and 15 deletions
13
lib/tar.js
generated
13
lib/tar.js
generated
|
|
@ -33,6 +33,7 @@ exports.inferCompressionMethod = inferCompressionMethod;
|
|||
const child_process_1 = require("child_process");
|
||||
const fs = __importStar(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const stream = __importStar(require("stream"));
|
||||
const toolrunner_1 = require("@actions/exec/lib/toolrunner");
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const safe_which_1 = require("@chrisgavin/safe-which");
|
||||
|
|
@ -123,17 +124,17 @@ async function extract(tarPath, compressionMethod, tarVersion, logger) {
|
|||
if (!tarVersion) {
|
||||
throw new Error("Could not determine tar version, which is required to extract a Zstandard archive.");
|
||||
}
|
||||
return await extractTarZst(fs.createReadStream(tarPath), tarVersion, logger);
|
||||
return await extractTarZst(tarPath, tarVersion, logger);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Extract a compressed tar archive
|
||||
*
|
||||
* @param file path to the tar
|
||||
* @param tar tar stream, or path to the tar
|
||||
* @param dest destination directory. Optional.
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
async function extractTarZst(tarStream, tarVersion, logger) {
|
||||
async function extractTarZst(tar, tarVersion, logger) {
|
||||
const dest = await createExtractFolder();
|
||||
try {
|
||||
// Initialize args
|
||||
|
|
@ -143,7 +144,7 @@ async function extractTarZst(tarStream, tarVersion, logger) {
|
|||
args.push("--warning=no-unknown-keyword");
|
||||
args.push("--overwrite");
|
||||
}
|
||||
args.push("-f", "-", "-C", dest);
|
||||
args.push("-f", tar instanceof stream.Readable ? "-" : tar, "-C", dest);
|
||||
process.stdout.write(`[command]tar ${args.join(" ")}\n`);
|
||||
const tarProcess = (0, child_process_1.spawn)("tar", args, { stdio: "pipe" });
|
||||
let stdout = "";
|
||||
|
|
@ -157,7 +158,9 @@ async function extractTarZst(tarStream, tarVersion, logger) {
|
|||
// Mimic the standard behavior of the toolrunner by writing stderr to stdout
|
||||
process.stdout.write(data);
|
||||
});
|
||||
tarStream.pipe(tarProcess.stdin);
|
||||
if (tar instanceof stream.Readable) {
|
||||
tar.pipe(tarProcess.stdin);
|
||||
}
|
||||
await new Promise((resolve, reject) => {
|
||||
tarProcess.on("exit", (code) => {
|
||||
if (code !== 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue