Skip to content

Commit

Permalink
Updated clean script.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmvanb committed Jun 20, 2024
1 parent 5f52999 commit d318411
Showing 1 changed file with 36 additions and 23 deletions.
59 changes: 36 additions & 23 deletions scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.'

0 comments on commit d318411

Please sign in to comment.