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: check pm with a version number #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ravi-Rajpurohit
Copy link

No description provided.

@Ravi-Rajpurohit
Copy link
Author

Does this look good ?? Let me know if there are any changes.

if (wantedPM !== 'npm' && wantedPM !== 'pnpm' && wantedPM !== 'yarn') {
console.log(`"${wantedPM}" is not a valid package manager. Available package managers are: npm, pnpm, or yarn.`)
process.exit(1)
}
const usedPM = whichPMRuns()
if (usedPM && usedPM.name !== wantedPM) {
if (usedPM && usedPM.name !== wantedPM && usedPM.version !== wantedVersion) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about when the version is not specified? In that case it shouldn't be checked, right?

Suggested change
if (usedPM && usedPM.name !== wantedPM && usedPM.version !== wantedVersion) {
if (usedPM && (usedPM.name !== wantedPM || wantedVersion && usedPM.version !== wantedVersion)) {

@zkochan
Copy link
Member

zkochan commented Feb 16, 2022

Not sure if we need this feature as I know that pnpm, for instance, may verify its own version, using the engines field in package.json. Maybe other package managers do it as well.

https://pnpm.io/package_json#engines

@jimmyko
Copy link

jimmyko commented May 4, 2022

@zkochan Though the engine field can verify its own version, the pnpm still updates the lock file if someone run pnpm i, it's better to show a warning message to developer

@andersonba
Copy link

+1


Though the engine field can verify its own version, the pnpm still updates the lock file if someone run pnpm i, it's better to show a warning message to developer

Exactly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants