diff --git a/README.md b/README.md index 6717edf6..04231652 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/packages/cli/index.ts b/packages/cli/index.ts index 72a2c286..d7a5c706 100644 --- a/packages/cli/index.ts +++ b/packages/cli/index.ts @@ -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: @@ -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; @@ -582,13 +588,15 @@ 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", @@ -596,7 +604,7 @@ async function resolveTarball(pm: PackMethod, p: string, pJson: PackageJson) { }); const lines = stdout.split("\n").filter(Boolean); - if (pm !== "yarn") { + if (pm !== "yarn" && pm !== "bun") { filename = lines[lines.length - 1].trim(); }