Skip to content

Instantly share code, notes, and snippets.

@frangio
Last active May 26, 2017 21:06
Show Gist options
  • Save frangio/9a223ba22cbbc7ca1b5bc0f4d3bd276f to your computer and use it in GitHub Desktop.
Save frangio/9a223ba22cbbc7ca1b5bc0f4d3bd276f to your computer and use it in GitHub Desktop.
Git subcommand to clone an npm package's repository
#!/usr/bin/env sh
# usage: git npm-clone left-pad
set -o errexit
pkg="$1"
shift
url="$(npm view "$pkg" repository.url | sed 's/^git+//;t;q1')"
git clone "$url" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment