Skip to content

Instantly share code, notes, and snippets.

@amercier
Last active August 29, 2015 14:00
Show Gist options
  • Save amercier/11366318 to your computer and use it in GitHub Desktop.
Save amercier/11366318 to your computer and use it in GitHub Desktop.
bash <(curl -# -L https://gist.github.com/amercier/11366318/raw) <user> <directory>
#!/usr/bin/env bash
if [ "`whoami`" != "root" ]; then
echo "You must execute this script as root" >&2
exit 1
fi
if [ "$1" == "" ]; then
echo "Syntax: $0 USER DIRECTORY" >&2
exit 1
fi
if [ "$2" == "" ]; then
echo "Syntax: $0 USER DIRECTORY" >&2
exit 1
fi
npm cache clean \
&& sudo -u $1 -i npm cache clean \
&& for g in $(ls "$2" | egrep ^generator- | grep -v playground); do \
echo ===== $g ===== \
&& cd $2/$g \
&& sudo -u $1 -H npm install \
&& npm link \
|| exit 1; \
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment