Before I do a small release and tag it, I'd like to update the package.json to reflect the new version of the program.
Is there a way to edit the file package.json
automatically?
Would using a git pre-release hook
help?
gitgithooksnode.jsnpm
Before I do a small release and tag it, I'd like to update the package.json to reflect the new version of the program.
Is there a way to edit the file package.json
automatically?
Would using a git pre-release hook
help?
Best Answer
Right answer
To do so, just
npm version patch
=)My old answer
There is no
pre-release
hook originally ingit
. At least,man githooks
does not show it.If you're using
git-extra
(https://github.com/visionmedia/git-extras), for instance, you can use apre-release
hook which is implemented by it, as you can see at https://github.com/visionmedia/git-extras/blob/master/bin/git-release. It is needed only a.git/hook/pre-release.sh
executable file which edits yourpackage.json
file. Committing, pushing and tagging will be done by thegit release
command.If you're not using any extension for
git
, you can write a shell script (I'll name itgit-release.sh
) and than you can alias it togit release
with something like:git config --global alias.release '!sh path/to/pre-release.sh $1'
You can, than, use
git release 0.4
which will executepath/to/pre-release.sh 0.4
. Your script can editpackage.json
, create the tag and push it to the server.