Last active
March 27, 2019 20:26
-
-
Save fictorial/170646d403ff6be0606ed9c8025aef2b to your computer and use it in GitHub Desktop.
Install Node.js packages from NPM for any referenced package in JavaScript under current directory
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 | |
set -eu | |
trap 'rm -f .all .used' 0 1 2 3 6 9 15 | |
curl -s https://raw.githubusercontent.com/sindresorhus/builtin-modules/master/builtin-modules.json | jq -c '.[]' | sed -e 's/"//g' > .all | |
ack --js -h "require\('([^']+)'" --output '$1' | egrep -v '^\.' | sort -u > .used | |
npm i -S $(grep -Fvxf .all .used) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
assumes you have
ack
,jq
, andnpm