Created
August 5, 2018 20:26
-
-
Save coreyfarrell/a8d1aa2f2781207220eb6d6e8d9c08e6 to your computer and use it in GitHub Desktop.
Script to clone by npm name
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
#!/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