Skip to content

Commit c03b48e

Browse files
ryoppippiAmirSa12
andauthored
feat: add bun package manager support (#398)
Co-authored-by: AmirSa12 <[email protected]>
1 parent e2ea1fc commit c03b48e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ To customize which package manager is reflected in the comments, use the `--pack
202202

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

205-
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.
205+
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.
206206

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

packages/cli/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ const main = defineCommand({
7474
type: "boolean",
7575
description: "use `yarn pack` instead of `npm pack --json`",
7676
},
77+
bun: {
78+
type: "boolean",
79+
description: "use `bun pm pack` instead of `npm pack --json`",
80+
},
7781
template: {
7882
type: "string",
7983
description:
@@ -131,6 +135,8 @@ const main = defineCommand({
131135
packMethod = "pnpm";
132136
} else if (args.yarn) {
133137
packMethod = "yarn";
138+
} else if (args.bun) {
139+
packMethod = "bun";
134140
}
135141

136142
const isPeerDepsEnabled = !!args.peerDeps;
@@ -582,21 +588,23 @@ runMain(main)
582588
.then(() => process.exit(0))
583589
.catch(() => process.exit(1));
584590

585-
type PackMethod = "npm" | "pnpm" | "yarn";
591+
type PackMethod = "npm" | "pnpm" | "yarn" | "bun";
586592

587593
async function resolveTarball(pm: PackMethod, p: string, pJson: PackageJson) {
588594
let cmd = `${pm} pack`;
589595
let filename = `${pJson.name!.replace("/", "-")}-${pJson.version}.tgz`;
590596
if (pm === "yarn") {
591597
cmd += ` --filename ${filename}`;
598+
} else if (pm === "bun") {
599+
cmd = `bun pm pack --filename ${filename}`;
592600
}
593601
const { stdout } = await ezSpawn.async(cmd, {
594602
stdio: "overlapped",
595603
cwd: p,
596604
});
597605
const lines = stdout.split("\n").filter(Boolean);
598606

599-
if (pm !== "yarn") {
607+
if (pm !== "yarn" && pm !== "bun") {
600608
filename = lines[lines.length - 1].trim();
601609
}
602610

0 commit comments

Comments
 (0)