Brig
Brig

Reputation: 10321

versioning tool for nodejs

There are solutions to increment the version number in different application. Cocoa apps have agvtool and maven has the maven-release-plugin which increments the version number on releases. Are there similar tools for nodejs?

Upvotes: 2

Views: 3768

Answers (3)

justin.m.chase
justin.m.chase

Reputation: 13655

I think the most correct answer is to use npm version.

For example, to increment the major version of your package:

npm version major

This will increment the major version of your package and if it is a git repository it will also commit that change and create a tag of the same name of the version.

Follow up with:

git push
git push --tags

Upvotes: 2

Truffula
Truffula

Reputation: 99

grunt-bump provides version bumping, as well as git tagging/commit/push. There are similar packages for other build tools such as gulp-bump.

Similar functionality is also now available with npm version, but with fewer configuration options.

Upvotes: 0

user1207456
user1207456

Reputation:

I think such a tool seems excessively heavy-handed when the only thing you need to do to increment the version number in Node.js is something as simple as:

sed -i 's/0.1.2/0.2.4/' package.json

Will change the version for your Node.js package?

If you're talking about something that will deploy your code when you explicitly mark a new version, I'd be more inclined to use git hooks and write a script to detect when a git tag is created and then start the deployment process.

You could use the pre-applypatch hook to detect when a tag is being created to run the sed script listed above and run npm publish for you automatically, but again, I don't see the point of having a heavyweight tool handle all of that when it's a simple script away (and said script could be written in Node.js, too!)

Upvotes: 2

Related Questions