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

feat: added bun to package managers #108

Merged
merged 1 commit into from
Nov 2, 2023
Merged
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
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ inputs:
description: "The script used to generate size-limit results"
package_manager:
required: false
description: "The package manager used to run the build and install commands. If not provided, the manager will be auto detected. Example values: `yarn`, `npm`, `pnpm`."
description: "The package manager used to run the build and install commands. If not provided, the manager will be auto detected. Example values: `yarn`, `npm`, `pnpm`, `bun`."
runs:
using: 'node12'
main: 'dist/index.js'
14 changes: 11 additions & 3 deletions src/Term.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,27 @@ import { exec } from "@actions/exec";
import hasYarn from "has-yarn";
import hasPNPM from "has-pnpm";

import process from 'node:process';
import path from 'node:path';
import fs from 'node:fs';

function hasBun(cwd = process.cwd()) {
return fs.existsSync(path.resolve(cwd, 'bun.lockb'));
}

const INSTALL_STEP = "install";
const BUILD_STEP = "build";

class Term {
/**
* Autodetects and gets the current package manager for the current directory, either yarn, pnpm,
* Autodetects and gets the current package manager for the current directory, either yarn, pnpm, bun,
* or npm. Default is `npm`.
*
* @param directory The current directory
* @returns The detected package manager in use, one of `yarn`, `pnpm`, `npm`
* @returns The detected package manager in use, one of `yarn`, `pnpm`, `npm`, `bun`
*/
getPackageManager(directory?: string): string {
return hasYarn(directory) ? "yarn" : hasPNPM(directory) ? "pnpm" : "npm";
return hasYarn(directory) ? "yarn" : hasPNPM(directory) ? "pnpm" : hasBun(directory) ? "bun" : "npm";
}

async execSizeLimit(
Expand Down
Loading