Created
December 9, 2015 11:40
-
-
Save Rob--W/56cff1b191b23b860118 to your computer and use it in GitHub Desktop.
Downloads and extracts specific npm package without dependencies or hooks.
This file contains hidden or 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/bash | |
# Downloads and extracts specific npm package without dependencies or hooks. | |
# Usage: | |
# npm-download-only [package1] [package2] ... | |
# where package can be a specific version (e.g. [email protected]) or package. | |
# | |
# Written on 9 dec 2015 by Rob Wu (https://robwu.nl) | |
for arg in "$@" | |
do | |
if [ -e "$arg" ] ; then | |
echo "$arg exists already -- skipping." | |
continue | |
fi | |
tarball=$(npm view "$arg" dist.tarball) | |
if [ -z "$tarball" ] ; then | |
echo "No dist.tarball found for '$arg'" | |
continue | |
fi | |
if ! mkdir "$arg" ; then | |
echo "Failed to create directory '$arg'" | |
continue | |
fi | |
echo "Downloading '$tarball' and extracting it to '$arg'" | |
curl "$tarball" | tar xz --strip-components 1 --directory "$arg" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment