0

Let's say i have a library and when i compile it with webpack i also add a banner such as this one: // LibraryName vX.X where vX.X is its version.

I want to compile it with npm preversion script. As here:

"preversion": "gulp build --version MYVERSION"

Where MYVERSION is a semver version that will appear in package.json after calling npm version.

How can i get that MYVERSION from CLI command?

EDIT

I know i can simply get version from package.json if i run it with postversion, but i want build be before adding a git tag.

brandonscript
  • 68,675
  • 32
  • 163
  • 220

1 Answers1

0

Closing this question, because i found the answer.

TL;DR The answer is: Use version instead of preversion in npm-scripts.

You can found more details here in explanation of scripts order.

Run the version script. These scripts have access to the new version in package.json