-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[feature] npm_version_specifier as the way to know how npm version command was called #8098
Comments
@ThePlenkov You might want to check this https://docs.npmjs.com/cli/v11/using-npm/scripts#npm-version cli/workspaces/libnpmversion/lib/version.js Lines 62 to 72 in 3a80a7b
|
That's ok, but that's what I want to say is that I can only have exact versions, old and new. But not the specifier like patch or minor. |
you can derive/calculate this using something like ~/workarea/test-repo $ cat test.js
const semver = require('semver')
console.log(semver.diff('1.1.0', '1.1.1'))
console.log(semver.diff('1.0.0', '1.1.0'))
console.log(semver.diff('1.1.0', '2.0.0'))
~/workarea/test-repo $ node test.js
patch
minor
major |
Of course. But point is - we are already calling a command with the specifier. So would be nice to have this argument propagated as a variable. But surely thanks for the recommendation- that's a working code indeed. |
Context
I'd like to develop an extension for
npm version
commandIn a script I'd like to know how the version was called, like patch, minor or any else
Problem
Unfortunately currently it is not possible to know what is a version specifier
Solution
We already have set of predefined variables, like npm_package_version, but it's not helping here to know what was the instruction.
So having a variable like
npm_version_specifier
would help a lot.Thanks!
The text was updated successfully, but these errors were encountered: