Skip to content

Commit 8c3a732

Browse files
committed
Bundle install: Only use stdin for streaming
1 parent b35b023 commit 8c3a732

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

lib/tar.js

Lines changed: 8 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/tar.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tar.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,19 @@ export async function extract(
125125
"Could not determine tar version, which is required to extract a Zstandard archive.",
126126
);
127127
}
128-
return await extractTarZst(
129-
fs.createReadStream(tarPath),
130-
tarVersion,
131-
logger,
132-
);
128+
return await extractTarZst(tarPath, tarVersion, logger);
133129
}
134130
}
135131

136132
/**
137133
* Extract a compressed tar archive
138134
*
139-
* @param file path to the tar
135+
* @param tar tar stream, or path to the tar
140136
* @param dest destination directory. Optional.
141137
* @returns path to the destination directory
142138
*/
143139
export async function extractTarZst(
144-
tarStream: stream.Readable,
140+
tar: stream.Readable | string,
145141
tarVersion: TarVersion,
146142
logger: Logger,
147143
): Promise<string> {
@@ -157,7 +153,7 @@ export async function extractTarZst(
157153
args.push("--overwrite");
158154
}
159155

160-
args.push("-f", "-", "-C", dest);
156+
args.push("-f", tar instanceof stream.Readable ? "-" : tar, "-C", dest);
161157

162158
process.stdout.write(`[command]tar ${args.join(" ")}\n`);
163159

@@ -175,7 +171,9 @@ export async function extractTarZst(
175171
process.stdout.write(data);
176172
});
177173

178-
tarStream.pipe(tarProcess.stdin);
174+
if (tar instanceof stream.Readable) {
175+
tar.pipe(tarProcess.stdin);
176+
}
179177

180178
await new Promise<void>((resolve, reject) => {
181179
tarProcess.on("exit", (code) => {

0 commit comments

Comments
 (0)