Last active
July 19, 2016 20:55
-
-
Save eschaefer/737fe311d77fdc82ba35d764a91ab927 to your computer and use it in GitHub Desktop.
Swap node_modules folders when they're different between git branches
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
#!/bin/bash | |
# Assumes you are not committing node_modules to git. You really shouldn't... | |
# | |
# 1. Save bash script in some folder like $HOME/Scripts/ | |
# 2. Add nswap alias to your .bash_profile: | |
# alias nswap="bash $HOME/Scripts/node-modules-swap.sh" | |
e=$(ls | grep node_modules) | |
if [ $e == "node_modules" ]; then | |
echo "Swapping node_modules..." | |
mkdir ~/Scripts/nodeswap/old/ | |
cp -rf node_modules ~/Scripts/nodeswap/old | |
rm -rf node_modules | |
cp -rf ~/Scripts/nodeswap/new/node_modules ./ | |
rm -rf ~/Scripts/nodeswap/new | |
mv ~/Scripts/nodeswap/old ~/Scripts/nodeswap/new | |
else | |
echo "No node_modules folder found. Are you in the right directory?" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment