Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add bun support. #15

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 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
11 changes: 9 additions & 2 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ enum PackageManager {
NPM = "npm",
Yarn = "yarn",
PNPM = "pnpm",
Bun = "bun",
}

interface PackageManagerCommands {
Expand All @@ -61,6 +62,11 @@ const packageManagerCommands: {
devInstall: "pnpm install --silent -D",
build: "pnpm run build",
},
[PackageManager.Bun]: {
init: "bun init -y && rm -rf index.ts .gitignore tsconfig.json README.md",
acopier marked this conversation as resolved.
Show resolved Hide resolved
acopier marked this conversation as resolved.
Show resolved Hide resolved
devInstall: "bun install --silent -D",
build: "bun run build",
}
};

function cmd(cmdStr: string, cwd: string) {
Expand Down Expand Up @@ -109,14 +115,15 @@ async function init(argv: yargs.Arguments<InitOptions>, initMode: InitMode) {

// Although npm is installed by default, it can be uninstalled
// and replaced by another manager, so check for it to make sure
const [npmAvailable, pnpmAvailable, yarnAvailable, gitAvailable] = (
await Promise.allSettled(["npm", "pnpm", "yarn", "git"].map(v => lookpath(v)))
const [npmAvailable, pnpmAvailable, yarnAvailable, bunAvailable, gitAvailable] = (
await Promise.allSettled(["npm", "pnpm", "yarn", "bun", "git"].map(v => lookpath(v)))
).map(v => (v.status === "fulfilled" ? v.value !== undefined : true));

const packageManagerExistance: { [K in PackageManager]: boolean } = {
[PackageManager.NPM]: npmAvailable,
[PackageManager.PNPM]: pnpmAvailable,
[PackageManager.Yarn]: yarnAvailable,
[PackageManager.Bun]: bunAvailable
};

const packageManagerCount = Object.values(packageManagerExistance).filter(exists => exists).length;
Expand Down