Skip to content

Instantly share code, notes, and snippets.

View NathanielInman's full-sized avatar
🎯
Focusing

Nathaniel Inman NathanielInman

🎯
Focusing
View GitHub Profile
@NathanielInman
NathanielInman / example.sh
Created January 5, 2017 23:15
Getting version from a package.json from shell
# Using the package.json file itself:
# grep style
VERSION = `grep version package.json | cut -c 15- | rev | cut -c 3- | rev`
# sed style
VERSION = `sed -nE 's/^.*"version".*"(.*)",$/\1/p' package.json`
# awk style
VERSION = `awk '/version/{gsub(/("|",)/,"",$2);print $2};' package.json`
# Using npm run env instead
# grep style