Last active
July 12, 2018 15:21
-
-
Save efeminella/800b531f72bf799dbdd4d2f97b1fae28 to your computer and use it in GitHub Desktop.
Simple Bash script which cleans yarn cache / node_modules dir and reinstalls
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 | |
# Simple Bash script which cleans yarn cache / node_modules dir and reinstalls | |
# Source it from .bashrc, and run from dir $ reyarn | |
function reyarn() { | |
local BEGIN='\x1B[33m[BEGIN]: '; | |
local SUCCESS='\x1B[32m[SUCCESS]: '; | |
local FAILURE='\x1B[31m[FAILURE]: '; | |
local CLEAR='\x1B[0m'; | |
printf '\n\n'; | |
echo -e '\x1B[7m Re-installing Yarn / NPM Dependencies ' $CLEAR; | |
echo -e '----------------------------------------' $CLEAR; | |
echo -e $BEGIN 'Deleting node_modules directory ...' $CLEAR; | |
rm -rf node_modules > /dev/null 2>&1 | |
STATUS=$? | |
if [ $STATUS -eq 0 ]; then | |
echo -e $SUCCESS 'node_modules directory successfully deleted.' $CLEAR; | |
else | |
echo -e $FAILURE 'Error Deleting node_modules Directory.' $CLEAR; | |
exit $? | |
fi | |
echo -e $BEGIN 'Cleaning Yarn Cache ...' $CLEAR; | |
yarn cache clean > /dev/null 2>&1 | |
STATUS=$? | |
if [ $STATUS -eq 0 ]; then | |
echo -e $SUCCESS 'Yarn Cache Clean successfully completed.' $CLEAR; | |
else | |
echo -e $FAILURE 'Error Cleaning Yarn Cache.' $CLEAR; | |
exit $? | |
fi | |
echo -e $BEGIN 'Installing Yarn / NPM Dependencies ...' $CLEAR; | |
yarn install > /dev/null 2>&1 | |
STATUS=$? | |
if [ $STATUS -eq 0 ]; then | |
echo -e $SUCCESS 'Yarn / NPM Dependencies successfully installed.' $CLEAR; | |
else | |
echo -e $FAILURE 'Error Installing Yarn / NPM Dependencies.' $CLEAR; | |
exit $? | |
fi | |
echo -e '\x1B[7m Done! ' $CLEAR; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment