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
I want to add some clarity to the answers this question got.
Even thought there are some answers here that are tackling properly the problem and providing a solution, they are not the correct ones. The correct answer to this question is to use npm version
Is there a way to edit the file package.json automatically?
Yes, what you can do to make this happen is to run the npm version command when needed, you can read more about it here npm version, but the base usage would be npm version patch and it would add the 3rd digit order on your package.json version (1.0.X)
Would using a git pre-release hook help?
You could configure to run the npm version command on the pre-release hook, as you need, but that depends if that is what you need or not in your CD/CI pipe, but without the npm version command a git pre-release hook can't do anything "easily" with the package.json
The reason why npm version is the correct answer is the following:
package.json he is using npm if he is using npm he has access to the npm scripts.npm scripts he has access to the npm version command. The other answers in which other tools are proposed are incorrect.
gulp-bump works but requires another extra package which could create issues in the long term (point 3 of my answer)
grunt-bump works but requires another extra package which could create issues in the long term (point 3 of my answer)