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 support for Bun #756

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"npm": ">=9",
"git": ">=2.11.0",
"yarn": ">=1.7.0",
"pnpm": ">=8"
"pnpm": ">=8",
"bun": ">=1"
},
"scripts": {
"test": "xo && ava"
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- Warns about the possibility of extraneous files being published
- See exactly what will be executed with [preview mode](https://github.com/sindresorhus/np/issues/391), without pushing or publishing anything remotely
- Supports [GitHub Packages](https://github.com/features/packages)
- Supports npm 9+, Yarn (Classic and Berry), and pnpm 8+
- Supports npm 9+, Yarn (Classic and Berry), npm 8+, and Bun

### Why not

Expand Down
15 changes: 15 additions & 0 deletions source/package-manager/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,18 @@ export const yarnBerryConfig = {
throwOnExternalRegistry: true,
lockfiles: ['yarn.lock'],
};

/** @type {import('./types.d.ts').PackageManagerConfig} */
export const bunConfig = {
cli: 'bun',
id: 'bun',
installCommand: ['bun', ['install', '--frozen-lockfile']],
installCommandNoLockfile: ['bun', ['install', '--no-save']],
versionCommand: version => ['npm', ['version', version]],
// Bun doesn't support publishing, so we use npm instead. See https://github.com/oven-sh/bun/issues/5050
publishCommand: arguments_ => ['npm', arguments_],
// TODO: Bun doesn't support config get registry, this should be added in the future. See https://github.com/oven-sh/bun/issues/7140
getRegistryCommand: ['npm', ['config', 'get', 'registry']],
tagVersionPrefixCommand: ['npm', ['config', 'get', 'tag-version-prefix']],
lockfiles: ['bun.lockb'],
};
4 changes: 4 additions & 0 deletions source/package-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ function configFromPackageManagerField(package_) {
return configs.yarnConfig;
}

if (packageManager === 'bun') {
return configs.bunConfig;
}

throw new Error(`Invalid package manager: ${package_.packageManager}`);
}

Expand Down