Last active
August 29, 2015 14:06
-
-
Save martinheidegger/5217df563c8e1edcacbd to your computer and use it in GitHub Desktop.
Shell script to install a package locally and automatically put a require statement in the clipboard. (mac) "$ curl -sL http://git.io/MPadbw >> ~/.zshrc"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# npm-i (https://gist.github.com/martinheidegger/5217df563c8e1edcacbd) | |
# Helper to make installing a package in node-js more comfortable. | |
# | |
npm-i() { | |
if [[ -z "$1" ]]; then | |
echo "Usage: npm-i <package> (var)" | |
else | |
npm install $1 --save | |
if [[ "$2" == "var" ]]; then | |
stmt="var $1 = require(\"$1\");" | |
else | |
stmt="require(\"$1\");" | |
fi | |
echo "Adding '$stmt' to clipboard." | |
echo "$stmt" | pbcopy | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment