From d318411b242f09859b1d160edfede93e840db40a Mon Sep 17 00:00:00 2001 From: Casper Date: Thu, 20 Jun 2024 23:21:39 +0200 Subject: [PATCH] Updated clean script. --- scripts/clean.sh | 59 +++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/scripts/clean.sh b/scripts/clean.sh index 7d16929..ff7ee1a 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -5,32 +5,45 @@ set -euo pipefail -empty_directory() { - if [[ -d "$1" ]]; then - rm $1/* - echo "Emptied $1." - else - echo "$1 doesn't exist." +# Empty directories. +#------------------------------------------------------------------------------- +declare -a dirs=( + "cookbook/static/user_images" +) + +for dir in "${dirs[@]}"; do + if [[ -d "$dir" ]]; then + rm "$dir"/* + echo "Emptied $dir." fi -} - -remove_file() { - if [[ -f "$1" ]]; then - rm $1 - echo "Removed $1." - else - echo "$1 doesn't exist." +done + +# Remove directories. +#------------------------------------------------------------------------------- +declare -a dirs=( + ".pytest_cache" +) + +for dir in "${dirs[@]}"; do + if [[ -d "$dir" ]]; then + rm -r "$dir" + echo "Removed $dir." fi -} +done -user_images_dir=cookbook/static/user_images -database=instance/cookbook.sqlite -coverage_report=.coverage -session_json=session.json +# Remove files. +#------------------------------------------------------------------------------- +declare -a files=( + "instance/cookbook.sqlite" + ".coverage" + "session.json" +) -empty_directory $user_images_dir -remove_file $database -remove_file $coverage_report -remove_file $session_json +for file in "${files[@]}"; do + if [[ -f "$file" ]]; then + rm "$file" + echo "Removed $file." + fi +done echo 'clean.sh complete.'