Skip to content

Commit

Permalink
Handle multiple lockfiles including Bun
Browse files Browse the repository at this point in the history
  • Loading branch information
Strengthless committed Sep 10, 2023
1 parent 6226e98 commit d1d25b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ team.

- `--use-yarn`

By default, patch-package checks whether you use npm or yarn based on which
lockfile you have. If you have both, it uses npm by default. Set this option
to override that default and always use yarn.
By default, patch-package checks whether you use npm, yarn or bun based on
which lockfile you have. If you have multiple lockfiles, it uses npm by
default. Set this option to override that default and always use yarn.

- `--exclude <regexp>`

Expand Down
10 changes: 8 additions & 2 deletions src/detectPackageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function printSelectingDefaultMessage() {
console.info(
`${chalk.bold(
"patch-package",
)}: you have both yarn.lock and package-lock.json
)}: you have multiple lockfiles, e.g. yarn.lock and package-lock.json
Defaulting to using ${chalk.bold("npm")}
You can override this setting by passing --use-yarn or deleting
package-lock.json if you don't need it
Expand All @@ -54,7 +54,13 @@ export const detectPackageManager = (
const bunLockbExists = fs.existsSync(
join(findWorkspaceRoot() ?? appRootPath, "bun.lockb"),
)
if ((packageLockExists || shrinkWrapExists) && yarnLockExists) {
if (
[
packageLockExists || shrinkWrapExists,
yarnLockExists,
bunLockbExists,
].filter(Boolean).length > 1
) {
if (overridePackageManager) {
return overridePackageManager
} else {
Expand Down

0 comments on commit d1d25b6

Please sign in to comment.