Skip to content

Commit d1d25b6

Browse files
committed
Handle multiple lockfiles including Bun
1 parent 6226e98 commit d1d25b6

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ team.
152152

153153
- `--use-yarn`
154154

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

159159
- `--exclude <regexp>`
160160

src/detectPackageManager.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function printSelectingDefaultMessage() {
2929
console.info(
3030
`${chalk.bold(
3131
"patch-package",
32-
)}: you have both yarn.lock and package-lock.json
32+
)}: you have multiple lockfiles, e.g. yarn.lock and package-lock.json
3333
Defaulting to using ${chalk.bold("npm")}
3434
You can override this setting by passing --use-yarn or deleting
3535
package-lock.json if you don't need it
@@ -54,7 +54,13 @@ export const detectPackageManager = (
5454
const bunLockbExists = fs.existsSync(
5555
join(findWorkspaceRoot() ?? appRootPath, "bun.lockb"),
5656
)
57-
if ((packageLockExists || shrinkWrapExists) && yarnLockExists) {
57+
if (
58+
[
59+
packageLockExists || shrinkWrapExists,
60+
yarnLockExists,
61+
bunLockbExists,
62+
].filter(Boolean).length > 1
63+
) {
5864
if (overridePackageManager) {
5965
return overridePackageManager
6066
} else {

0 commit comments

Comments
 (0)