Skip to content

Instantly share code, notes, and snippets.

@branning
Last active July 20, 2016 04:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save branning/746aaade9fdda997a93e5772b578702c to your computer and use it in GitHub Desktop.
Save branning/746aaade9fdda997a93e5772b578702c to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# alias for npm that only uses git over https
set -o errexit # exit on any error
real_npm=`which npm`
npm_install()
{
# quit if we can't find 'packages.json'
! [ -f packages.json ] && { echo "`basename $0`: cannot find package.json"; exit 1; }
# rewrite 'git@github.com:' ssh urls to 'https://github.com/'
sed 's|git@github\.com:|https://github.com/|' package.json > package_https.json
$real_npm install package_https.json
}
case "$1" in
install) npm_install $@ ;;
*) $real_npm $@
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment