How to run script during npm version

Is there a way to run the script at a time npm versionthat starts after the version number has been incremented, but before creating and clicking the git tag?

+4
source share
2 answers

You can create a versionscript that will be called after the extension of the package version, but before the commit and tag.

"scripts": {
  "version": "./your_script"
}

Check the execution order as per the npm version documentation . Below you can see an interesting excerpt, in particular paragraph 4:

  • Make sure the git working directory is clean before we get started. Your scripts can add files to the commit in future steps. This step is skipped if the -force flag is set.
  • script. package.json. . , , git add.
  • Bump .json (, , ..).
  • script. package.json( , ). , commit git add.
  • Commit tag.
  • postversion script. / .

npm v2.13.0. . : commit .

+2

https://docs.npmjs.com/misc/scripts , :

  • preversion, version: Run BEFORE bump .
  • postversion: AFTER, .

package.json:

"scripts": { "postversion" : "./your_script" }

, : https://docs.npmjs.com/misc/scripts#hook-scripts

0

All Articles