Created
January 24, 2014 17:15
-
-
Save dstokes/8601766 to your computer and use it in GitHub Desktop.
NPM failover in bash
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
# description: | |
# implement npmjs registry failover in your shell | |
# | |
# setup: | |
# npm install -g npm-delegate | |
# | |
# usage: | |
# npms install through | |
# npms i through async | |
# | |
npms() { | |
PORT=5983 | |
REGLIST="http://registry.npmjs.org http://registry.nodejitsu.com http://registry.npmjs.eu" | |
(npm-delegate $REGLIST &) | |
# wait for the delegate server | |
while ! nc -vz localhost $PORT &> /dev/null ; do sleep 1; done | |
# shadow npm command with registry argument | |
npm --registry http://localhost:$PORT "$@" | |
kill $(ps aux | grep 'npm-delegate' | awk '{print $2}') | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i think im just going to go with trying all of them and using an install command
cd module && npmi