Skip to content

Instantly share code, notes, and snippets.

@DamonOehlman
Last active December 28, 2015 04:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DamonOehlman/7443415 to your computer and use it in GitHub Desktop.
Save DamonOehlman/7443415 to your computer and use it in GitHub Desktop.
In preparation for potentially having no net access for a while, I'm using @dominictarr's [npmd](https://github.com/dominictarr/npmd) to bring modules I need (or potentially might use down locally). I'm sure the script can use some improvements, but it works well enough for me know.Basically, head into a parent directory somewhere where you have…
#!/usr/bin/env bash
getopts ":r:" RECURSE
for dir in *; do
if [ -d "${dir}" ]; then
pushd "$dir" > /dev/null
if [ -e package.json ]; then
echo "reinstalling packages with npmd for: ${dir}"
rm -rf node_modules
npmd install
# if npmd failed, then abort
if [ $? -ne 0 ]; then
exit $?
fi
elif [ $RECURSE = ":" ]; then
npmd-all-the-things -r
fi
popd > /dev/null
fi
done
@brianleroux
Copy link

seems legit

@dominictarr
Copy link

Yeah this should work!
Please post an issue on any modules npmd can't install.

@DamonOehlman
Copy link
Author

Made a recursive mode...

@DamonOehlman
Copy link
Author

Added to djo-shell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment