Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ To customize which package manager is reflected in the comments, use the `--pack

For repositories with many packages, comments might get too long. In that case, you can use `--only-templates` to only show templates.

pkg.pr.new uses `npm pack --json` under the hood, in case you face issues, you can also use the `--pnpm` or `--yarn` flag so it starts using `pnpm pack` or `yarn pack`. This is not necessary in most cases.
pkg.pr.new uses `npm pack --json` under the hood, in case you face issues, you can also use the `--pnpm`, `--yarn`, or `--bun` flag so it starts using `pnpm pack`, `yarn pack`, or `bun pm pack`. This is not necessary in most cases.

<img width="100%" src="https://github.com/stackblitz-labs/pkg.pr.new/assets/37929992/2fc03b94-ebae-4c47-a271-03a4ad5d2449" />

Expand Down
12 changes: 10 additions & 2 deletions packages/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ const main = defineCommand({
type: "boolean",
description: "use `yarn pack` instead of `npm pack --json`",
},
bun: {
type: "boolean",
description: "use `bun pm pack` instead of `npm pack --json`",
},
template: {
type: "string",
description:
Expand Down Expand Up @@ -131,6 +135,8 @@ const main = defineCommand({
packMethod = "pnpm";
} else if (args.yarn) {
packMethod = "yarn";
} else if (args.bun) {
packMethod = "bun";
}

const isPeerDepsEnabled = !!args.peerDeps;
Expand Down Expand Up @@ -582,21 +588,23 @@ runMain(main)
.then(() => process.exit(0))
.catch(() => process.exit(1));

type PackMethod = "npm" | "pnpm" | "yarn";
type PackMethod = "npm" | "pnpm" | "yarn" | "bun";

async function resolveTarball(pm: PackMethod, p: string, pJson: PackageJson) {
let cmd = `${pm} pack`;
let filename = `${pJson.name!.replace("/", "-")}-${pJson.version}.tgz`;
if (pm === "yarn") {
cmd += ` --filename ${filename}`;
} else if (pm === "bun") {
cmd = `bun pm pack --filename ${filename}`;
}
const { stdout } = await ezSpawn.async(cmd, {
stdio: "overlapped",
cwd: p,
});
const lines = stdout.split("\n").filter(Boolean);

if (pm !== "yarn") {
if (pm !== "yarn" && pm !== "bun") {
filename = lines[lines.length - 1].trim();
}

Expand Down