"vpub" bash function that automatically increments your project's version number, pushes to git, and publishes to npm.

Just paste this function into your .bash_profile.

function vpub() {  
    npm version $1;
    git push origin master;
    npm publish;

Then you'll be able to do vpub patch/minor/major and it will:

  1. Automatically increment the version number in package.json.

  2. Tag your latest commit with the new version number.

  3. Push the changes to package.json and the git tag up to origin/master.

  4. Publishes your updated package to npm.

Just make sure you've committed all your changes and your working directory is clean before you do this or it will fail when trying to add the git tag to your repository with the version number.


Read more posts by this author.

comments powered by Disqus