Created
September 17, 2018 19:50
-
-
Save justsml/4835e569f95733bbb5e99c5678645950 to your computer and use it in GitHub Desktop.
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/bash | |
PACKAGES=$(cat "${1:-/dev/stdin}" | \ | |
grep "require([\"'][^'\"]*.)" | \ | |
sed 's/^[^(]*(.//g' | \ | |
sed 's/.[\)]*[a-zA-Z;]*$//' | \ | |
sed "s/.[)].*$//" | \ | |
sort | uniq) | |
# Remove NodeJS built-ins | |
PACKAGES=$(echo $PACKAGES | \ | |
sed 's/^assert//' | \ | |
sed 's/^buffer//' | \ | |
sed 's/^child_process//' | \ | |
sed 's/^cluster//' | \ | |
sed 's/^console//' | \ | |
sed 's/^constants//' | \ | |
sed 's/^crypto//' | \ | |
sed 's/^dgram//' | \ | |
sed 's/^dns//' | \ | |
sed 's/^domain//' | \ | |
sed 's/^events//' | \ | |
sed 's/^fs//' | \ | |
sed 's/^http//' | \ | |
sed 's/^https//' | \ | |
sed 's/^module//' | \ | |
sed 's/^net//' | \ | |
sed 's/^os//' | \ | |
sed 's/^path//' | \ | |
sed 's/^punycode//' | \ | |
sed 's/^querystring//' | \ | |
sed 's/^readline//' | \ | |
sed 's/^repl//' | \ | |
sed 's/^stream//' | \ | |
sed 's/^string_decoder//' | \ | |
sed 's/^sys//' | \ | |
sed 's/^timers//' | \ | |
sed 's/^tls//' | \ | |
sed 's/^tty//' | \ | |
sed 's/^url//' | \ | |
sed 's/^util//' | \ | |
sed 's/^vm//' | \ | |
sed 's/^zlib//') | |
echo "$PACKAGES" | xargs -n1 echo 'npm install' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment