Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

#Enter your directory below where plugin is located or place the script in the plugin directory
PLUGIN_DIR="."

ZIP_FILE="$PLUGIN_DIR/woocommerce-plugin.zip"

EXCLUDE_LIST=(
"$PLUGIN_DIR/.git/*"
"$PLUGIN_DIR/.plugin.sh"
)


if [ -f "$ZIP_FILE" ]; then
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't it be better to add a prompt asking the user whether to overwrite the existing file ?

echo "The ZIP file '$ZIP_FILE' already exists."
read -p "Do you want to overwrite it? (y/n): " choice
if [[ "$choice" != "y" && "$choice" != "Y" ]]; then
echo "Operation canceled. The ZIP file was not overwritten."
exit 1
fi
fi

EXCLUDE_PARAMS=()
for item in "${EXCLUDE_LIST[@]}"; do
EXCLUDE_PARAMS+=("-x" "$item")
done

if zip -r "$ZIP_FILE" "$PLUGIN_DIR" "${EXCLUDE_PARAMS[@]}"; then
echo "ZIP file created successfully: $ZIP_FILE"
else
echo "Failed to create ZIP file. Please check file permissions, disk space, and try again."
exit 1
fi