Skip to content

Commit

Permalink
Add support for Bun (#104)
Browse files Browse the repository at this point in the history
* Support `bun` package manager

* Remove changes caused by local formatter (oops)
  • Loading branch information
jack-weilage committed Apr 22, 2024
1 parent 8a15fc9 commit 7c0ed9e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A GitHub action that reports changes in compressed file sizes on your PRs.

- Automatically uses `yarn`, `pnpm` or `npm ci` when lockfiles are present
- Automatically uses `yarn`, `pnpm`, `bun`, or `npm ci` when lockfiles are present
- Builds your PR, then builds the target and compares between the two
- Doesn't upload anything or rely on centralized storage
- Supports [custom build scripts](#customizing-the-build) and [file patterns](#customizing-the-list-of-files)
Expand Down
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ async function run(octokit, context, token) {

let yarnLock = await fileExists(path.resolve(cwd, 'yarn.lock'));
let pnpmLock = await fileExists(path.resolve(cwd, 'pnpm-lock.yaml'));
let bunLock = await fileExists(path.resolve(cwd, 'bun.lockb'));
let packageLock = await fileExists(path.resolve(cwd, 'package-lock.json'));

let packageManager = 'npm';
Expand All @@ -62,6 +63,9 @@ async function run(octokit, context, token) {
} else if (pnpmLock) {
installScript = 'pnpm install --frozen-lockfile';
packageManager = 'pnpm';
} else if (bunLock) {
installScript = 'bun install --frozen-lockfile';
packageManager = 'bun';
} else if (packageLock) {
installScript = 'npm ci';
}
Expand Down Expand Up @@ -121,6 +125,7 @@ async function run(octokit, context, token) {

yarnLock = await fileExists(path.resolve(cwd, 'yarn.lock'));
pnpmLock = await fileExists(path.resolve(cwd, 'pnpm-lock.yaml'));
bunLock = await fileExists(path.resolve(cwd, 'bun.lockb'));
packageLock = await fileExists(path.resolve(cwd, 'package-lock.json'));

packageManager = 'npm';
Expand All @@ -131,6 +136,9 @@ async function run(octokit, context, token) {
} else if (pnpmLock) {
installScript = `pnpm install --frozen-lockfile`;
packageManager = `pnpm`;
} else if (bunLock) {
installScript = `bun install --frozen-lockfile`;
packageManager = `bun`;
} else if (packageLock) {
installScript = `npm ci`;
}
Expand Down

0 comments on commit 7c0ed9e

Please sign in to comment.