Created
March 14, 2019 20:43
-
-
Save brysgo/d151c0eda468f26d922555585951594d to your computer and use it in GitHub Desktop.
Bash script to link all the packages in a half baked mono repo
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 | |
for d in ./packages/*/ ; do | |
echo "" | |
echo "##################################################" | |
echo "##" | |
echo "## Linking in $d" | |
echo "##" | |
echo "" | |
echo | |
cd "$d" | |
deps_to_link=$(cat package.json | grep "\"file:.." | sed -e 's/".*": "file:\(.*\)".*/npm link "\1"/') | |
if [ -z "$deps_to_link" ] | |
then | |
echo "skipping $d, no relative deps" | |
cd ../../ | |
continue | |
fi | |
default_IFS=$IFS | |
IFS=$'\n' | |
for link_cmd in $deps_to_link ; do | |
echo $link_cmd | |
eval $link_cmd | |
status=$? | |
if [ $status -ne 0 ] | |
then | |
exit $status | |
fi | |
done | |
IFS=$default_IFS | |
cd ../../ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment