Skip to content

Instantly share code, notes, and snippets.

@joates
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save joates/1183b8f3a909804af8d2 to your computer and use it in GitHub Desktop.

Select an option

Save joates/1183b8f3a909804af8d2 to your computer and use it in GitHub Desktop.
[bash] extracts version info from package.json ( \1= Major \2=Minor \3=Patch )
# example usage
# -------------
# "version": "1.2.3-beta"
#
# value captured by `sed -e`
# --------------------------
#
# \1 = 1 (major)
# \2 = 2 (minor)
# \3 = 3-beta (patch)
node -e 'console.log(require("./package.json").version)' |sed -e 's/^\([0-9]\+\)\.\([0-9]\+\)\.\([a-zA-Z0-9-]\+\)$/\3/'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment