Skip to content

Instantly share code, notes, and snippets.

@brysgo
Created March 14, 2019 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brysgo/d151c0eda468f26d922555585951594d to your computer and use it in GitHub Desktop.
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
#!/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