# Function to delete node_modules directory, clean package # manager's global cache and install dependencies based on lock file # Usage: __nodeWipeInstall function __nodeWipeInstall(){ RED=`tput setaf 1` GREEN=`tput setaf 2` RESET=`tput sgr0` BOLD=$(tput bold) echo -e "${BOLD}${GREEN}*************** DELETING NODE_MODULES *******************${RESET}" find . -name "node_modules" -type d -prune -print -exec rm -rf "{}" \; wait if [[ -f "${PWD}/package-lock.json" ]]; then echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}************** clearning global npm cache' **************${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" npm cache clean --force echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}*************** installing using 'npm ci' ***************${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" npm ci elif [[ -f "${PWD}/yarn.lock" ]]; then echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}************* clearning global yarn cache' **************${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" yarn cache clean echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}*** installing using 'yarn install --frozen-lockfile' ***${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" yarn install --frozen-lockfile elif [[ -f "${PWD}/pnpm-lock.yaml" ]]; then echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}************* clearning global pnpm cache' **************${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" pnpm store prune echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}*** installing using 'pnpm install --frozen-lockfile' ***${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" pnpm i --frozen-lockfile else echo -e "${BOLD}${RED}***********************************************************${RESET}" echo -e "${BOLD}${RED}****************** no lock file found *********************${RESET}" echo -e "${BOLD}${RED}*********** please run pnpm/npm/yarn install **************${RESET}" echo -e "${BOLD}${RED}***********************************************************${RESET}" fi } # Function to delete node_modules directory and install dependencies based on lock file # Usage: __nodeWipeInstall function __nodeWipeInstall(){ RED=`tput setaf 1` GREEN=`tput setaf 2` BLUE=`tput setaf 5` RESET=`tput sgr0` BOLD=$(tput bold) echo -e "${BOLD}${GREEN}*************** DELETING NODE_MODULES *******************${RESET}" find . -name "node_modules" -type d -prune -print -exec rm -rf "{}" \; wait if [[ -f "${PWD}/package-lock.json" ]]; then echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}*************** installing using 'npm ci' ***************${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" npm ci elif [[ -f "${PWD}/yarn.lock" ]]; then echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}*** installing using 'yarn install --frozen-lockfile' ***${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" yarn install --frozen-lockfile elif [[ -f "${PWD}/pnpm-lock.yaml" ]]; then echo -e "${BOLD}${GREEN}*********************************************************${RESET}" echo -e "${BOLD}${GREEN}*** installing using 'pnpm install --frozen-lockfile' ***${RESET}" echo -e "${BOLD}${GREEN}*********************************************************${RESET}" pnpm i --frozen-lockfile else echo -e "${BOLD}${RED}***********************************************************${RESET}" echo -e "${BOLD}${RED}****************** no lock file found *********************${RESET}" echo -e "${BOLD}${RED}*********** please run pnpm/npm/yarn install **************${RESET}" echo -e "${BOLD}${RED}***********************************************************${RESET}" fi } alias nci="__nodeCleanInstall" alias nwi="__nodeWipeInstall"