diff --git a/scripts/publish.sh b/scripts/publish.sh index db50f9a..1921471 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -69,21 +69,8 @@ find -L "$SOURCE_DIR" -type f -name "*.md" -exec grep -q "publish: true" {} \; - fi done -# Log the script execution -echo "Executing cleanup script at $(date)" - -# Find files in DEST_DIR that don't exist in SOURCE_DIR and delete them -find "$DEST_DIR" -type f -exec sh -c ' - relative_path=${1#$DEST_DIR/} - source_file="$SOURCE_DIR/$relative_path" - - if [ ! -e "$source_file" ]; then - echo "Deleting $1 as it doesn't exist in SOURCE_DIR" - rm "$1" - else - echo "Skipping $1 as it exists in SOURCE_DIR" - fi -' _ {} \; +# Delete files in DEST_DIR that don't exist in SOURCE_DIR anymore +find "$DEST_DIR" -type f -exec sh -c '[ ! -e "$SOURCE_DIR/${1#$DEST_DIR/}" ] && rm "$1"' _ {} \; # Print the log file cat "$LOG_FILE"