lante lante - 5 months ago 9
Node.js Question

when running npm version, use that new version on preversion task

I am using

npm version [patch|minor|major]
to manage versions on my module.

But when running the task (
npm version
), I need the new version number to be used on a task (to print that version on the minified file, for example):

"preversion": "npm run grunt build --package-version={$something} && foo"


Is it possible to get the version number being generated to be used on the
npm preversion
task?
If so, how?

Answer

The solution was to put the task on the version script on the package.json file, so when the task version runs, it has the new version number on the package.json.

Comments