-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail on conflicting package manager metadata in package.json
Along with lockfile detection, we also detect what intended package manager (and version) should be used based on metadata found in package.json. When multiple package managers are declared we should fail the build early and ask the user to correct any conflicts found. Related to #1313
- Loading branch information
1 parent
15350cd
commit 99a2b5f
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
test/fixtures/conflicting-package-manager-metadata/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "conflicting-package-manager-metadata", | ||
"version": "1.0.0", | ||
"license": "ISC", | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
"npm": "10.x", | ||
"yarn": "4.x", | ||
"pnpm": "9.x" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2018,6 +2018,16 @@ testWarningNode_22_5_0() { | |
assertCapturedSuccess | ||
} | ||
|
||
testConflictingPackageManagerMetadata() { | ||
compile "conflicting-package-manager-metadata" | ||
assertCaptured "Multiple package managers declared in package.json" | ||
assertCaptured "- npm version detected in engines.npm (10.x)" | ||
assertCaptured "- yarn version declared in engines.yarn (4.x)" | ||
assertCaptured "- pnpm version declared in engines.pnpm (9.x)" | ||
assertCaptured "- pnpm version declared in packageManager ([email protected])" | ||
assertCapturedError | ||
} | ||
|
||
# Utils | ||
|
||
pushd "$(dirname 0)" >/dev/null | ||
|