Last active
October 16, 2020 12:56
-
-
Save robCrawford/e4edf50b6b4905c8b4b9b4c5b0c5de98 to your computer and use it in GitHub Desktop.
Copies a directory from the current package into node_modules of a parent package
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
cp-dep() { | |
# Copy directory named $1 in current package to node_modules of package named $2 | |
# e.g. `cp-dep lib my-parent-app` | |
cd $(git rev-parse --show-toplevel) | |
package=$(node -p -e "require('./package.json').name") | |
dependency="$(cd .. && pwd)/$2/node_modules/$package" | |
to="$dependency/$1" | |
if [ -d $1 ] && [ -d $dependency ]; then | |
rm -rf $to && cp -r $1 $to | |
echo "Copied '$1' to '$to'" | |
else | |
echo "Not found!" | |
fi | |
cd - > /dev/null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment