@@ -17,6 +17,8 @@ const MIN_REQUIRED_GNU_TAR_VERSION = "1.31";
1717export type TarVersion = {
1818 type: "gnu" | "bsd";
1919 version: string;
20+ /** Path to the `tar` executable that reported this version. */
21+ path: string;
2022};
2123
2224async function getTarVersion(): Promise<TarVersion> {
@@ -39,14 +41,14 @@ async function getTarVersion(): Promise<TarVersion> {
3941 throw new Error("Failed to parse output of tar --version.");
4042 }
4143
42- return { type: "gnu", version: match[1] };
44+ return { type: "gnu", version: match[1], path: tar };
4345 } else if (stdout.includes("bsdtar")) {
4446 const match = stdout.match(/bsdtar ([0-9.]+)/);
4547 if (!match?.[1]) {
4648 throw new Error("Failed to parse output of tar --version.");
4749 }
4850
49- return { type: "bsd", version: match[1] };
51+ return { type: "bsd", version: match[1], path: tar };
5052 } else {
5153 throw new Error("Unknown tar version");
5254 }
@@ -171,10 +173,10 @@ export async function extractTarZst(
171173
172174 args.push("-f", tar instanceof stream.Readable ? "-" : tar, "-C", dest);
173175
174- process.stdout.write(`[command]tar ${args.join(" ")}\n`);
176+ process.stdout.write(`[command]${tarVersion.path} ${args.join(" ")}\n`);
175177
176178 await new Promise<void>((resolve, reject) => {
177- const tarProcess = spawn("tar" , args, { stdio: "pipe" });
179+ const tarProcess = spawn(tarVersion.path , args, { stdio: "pipe" });
178180
179181 let stdout = "";
180182 tarProcess.stdout?.on("data", (data: Buffer) => {
@@ -210,11 +212,11 @@ export async function extractTarZst(
210212 if (code !== 0) {
211213 reject(
212214 new CommandInvocationError(
213- "tar" ,
215+ tarVersion.path ,
214216 args,
215217 code ?? undefined,
216- stdout,
217218 stderr,
219+ stdout,
218220 ),
219221 );
220222 }
0 commit comments