Add --all flag

This commit is contained in:
2021-10-28 12:53:02 +03:00
parent f706e89c34
commit 75b13386d0

View File

@@ -5,6 +5,7 @@ args=("$@")
usage() { usage() {
echo "Clean Cache utility: clean-cache [OPTIONS]" echo "Clean Cache utility: clean-cache [OPTIONS]"
echo echo
echo " --all cleans all cache"
echo " --npm cleans npm cache by running 'npm cache clean -f'" echo " --npm cleans npm cache by running 'npm cache clean -f'"
echo " --yarn cleans yarn cache by running 'yarn cache clean'" echo " --yarn cleans yarn cache by running 'yarn cache clean'"
echo " --yay clean yay cache by simply deleting ~/.cache/yay content" echo " --yay clean yay cache by simply deleting ~/.cache/yay content"
@@ -15,14 +16,32 @@ if [ $# -eq 0 ] ; then
exit exit
fi 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 if [[ "${args[@]}" =~ "--npm" ]] ; then
npm cache clean -f >> /dev/null 2>> /dev/null __clean_npm
fi fi
if [[ "${args[@]}" =~ "--yarn" ]] ; then if [[ "${args[@]}" =~ "--yarn" ]] ; then
yarn cache clean >> /dev/null 2>> /dev/null __clean_yarn
fi fi
if [[ "${args[@]}" =~ "--yay" ]] ; then if [[ "${args[@]}" =~ "--yay" ]] ; then
rm -rf ~/.cache/yay/* __clean_yay
fi fi