Files
dotfiles/bin/clean-cache
2021-10-28 12:53:02 +03:00

48 lines
792 B
Bash
Executable File

#! /bin/bash
args=("$@")
usage() {
echo "Clean Cache utility: clean-cache [OPTIONS]"
echo
echo " --all cleans all cache"
echo " --npm cleans npm cache by running 'npm cache clean -f'"
echo " --yarn cleans yarn cache by running 'yarn cache clean'"
echo " --yay clean yay cache by simply deleting ~/.cache/yay content"
}
if [ $# -eq 0 ] ; then
usage
exit
fi
__clean_npm() {
npm cache clean -f &> /dev/null
}
__clean_yarn() {
yarn cache clean &> /dev/null
}
__clean_yay() {
rm -rf ~/.cache/yay
}
if [[ "$args[@]" =~ "--all" ]] ; then
__clean_npm && __clean_yarn && __clean_yay
exit
fi
if [[ "${args[@]}" =~ "--npm" ]] ; then
__clean_npm
fi
if [[ "${args[@]}" =~ "--yarn" ]] ; then
__clean_yarn
fi
if [[ "${args[@]}" =~ "--yay" ]] ; then
__clean_yay
fi