Skip to content

Instantly share code, notes, and snippets.

@coreyfarrell
Created August 5, 2018 20:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coreyfarrell/a8d1aa2f2781207220eb6d6e8d9c08e6 to your computer and use it in GitHub Desktop.
Save coreyfarrell/a8d1aa2f2781207220eb6d6e8d9c08e6 to your computer and use it in GitHub Desktop.
Script to clone by npm name
#!/bin/sh -e
npmname=$1
destination=/usr/src/npm/$npmname
if test -d $destination; then
echo "$npmname is already cloned into:"
echo " $destination"
exit 0
fi
gitrepo=$(npm info $npmname repository.url|sed -e 's|.*github.com/|github.com:|' -e 's/\.git$//')
if test -z $gitrepo; then
echo "Repo not found for $npmname."
exit 1
fi
git clone $gitrepo $destination
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment