-
-
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.
feat(pnpm): support package.json#packageManager
- Loading branch information
1 parent
d8e2870
commit ae263ca
Showing
5 changed files
with
70 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { readFileSync } from 'fs'; | ||
|
||
/** | ||
* This is specific to pnpm because it's the only package manager with | ||
* incompatibility between the lockfile and the package manager version. | ||
* | ||
* The source of truth is still the lock file type because `npm ci` only | ||
* installs from the lock file. | ||
* | ||
* That's to say if there's a package-lock.json, but the packageManager | ||
* is pnpm, then we'll still use npm. | ||
*/ | ||
export const detectPnpmVersionFromPackageManager = () => { | ||
try { | ||
const { packageManager } = JSON.parse(readFileSync('package.json', 'utf8')); | ||
if (packageManager.startsWith('pnpm')) { | ||
return packageManager.slice(4); | ||
} | ||
} catch {} | ||
}; |
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,6 @@ | ||
{ | ||
"packageManager": "pnpm@8.0.0", | ||
"dependencies": { | ||
"test-package": "^0.0.1" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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