Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,36 +696,39 @@ async function resolveTarball(pm: PackMethod, p: string, pJson: PackageJson) {
if (pm === "yarn") {
cmd += ` --filename ${filename}`;
} else if (pm === "bun") {
cmd = `bun pm pack --quiet --filename ${filename}`;
cmd = `bun pm pack --quiet --destination ${p}`;
}
const { stdout } = await ezSpawn.async(cmd, {
stdio: "overlapped",
cwd: p,
});
const lines = stdout.split("\n").filter(Boolean);

if (pm !== "yarn" && pm !== "bun") {
filename = lines[lines.length - 1].trim();
if (pm !== "yarn") {
const lines = stdout.split("\n").filter(Boolean);
filename = lines[lines.length - 1].trim().split(path.sep).pop()!;
}
if (pm === "bun") {

try {
const shasum = createHash("sha1")
.update(await fs.readFile(path.resolve(p, filename)))
.digest("hex");

return { filename, shasum };
} catch (error) {
console.error(`Failed to read tarball for shasum calculation`);
console.error(`[${pm} pack] expected filename: ${filename}`);
console.error(`[${pm} pack] stdout:\n${stdout}`);

const tgzFiles = fsSync
.readdirSync(p)
.filter((file) => file.endsWith(".tgz"));
const bunFilename = stdout.trim();
if (bunFilename) {
filename = bunFilename;
}
console.warn(`[bun pack] stdout:\n${stdout}`);
console.warn(
`[bun pack] expected filename: ${filename}; tgz files: ${tgzFiles.join(", ") || "(none)"}`,
);
}

const shasum = createHash("sha1")
.update(await fs.readFile(path.resolve(p, filename)))
.digest("hex");
console.error(
`[${pm} pack] tgz files in directory: ${tgzFiles.join(", ") || "(none)"}`,
);

return { filename, shasum };
throw error;
}
}

async function writeDeps(
Expand Down
Loading