Skip to content

Instantly share code, notes, and snippets.

@twolfson
Created September 16, 2012 22:30
Show Gist options
  • Save twolfson/3734644 to your computer and use it in GitHub Desktop.
Save twolfson/3734644 to your computer and use it in GitHub Desktop.
package.json version pre-commit incrementer
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
node -e "var f = './package.json', p = require(f), v = p.version || '0.0.0', a = v.split('.'), b; a[2] = +a[2] + 1; p.version = a.join('.'); require('fs').writeFileSync(f, JSON.stringify(p, null, 2));"
git add ./package.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment