Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash script for zipping plugin #25

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
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

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