Skip to content

Instantly share code, notes, and snippets.

@brianswisher
Last active January 21, 2017 15:22
Show Gist options
  • Save brianswisher/d9f69608db46881ee997ae0084a1b544 to your computer and use it in GitHub Desktop.
Save brianswisher/d9f69608db46881ee997ae0084a1b544 to your computer and use it in GitHub Desktop.
Get nginx version; command line
# cli
V=`nginx -v 2>&1 | tee`; echo "var re = /command not found/; var no = '$V'.match(re); if (no) { console.log('$V'.replace(re,'You don\'t have')) } else{ console.log('$V'.split('/').pop()) }" | node

# package
"scripts": {
    "nginx:v": "V=`nginx -v 2>&1 | tee`; echo \"var re = /command not found/; var no = '$V'.match(re); if (no) { console.log(unescape('$V'.replace(re,'You don%27t have'))) } else{ console.log('$V'.split('/').pop()) }\" | node"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment