Skip to content
Merged
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
12 changes: 9 additions & 3 deletions templates/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ WP_CORE_FILE="$WP_CORE_DIR"/wp-settings.php
download() {
if command -v curl > /dev/null 2>&1; then
curl -L -s "$1" > "$2";
return $?
elif command -v wget > /dev/null 2>&1; then
wget -nv -O "$2" "$1"
return $?
else
echo -e "${RED}Error: Neither curl nor wget is installed.${RESET}"
exit 1
Expand All @@ -43,10 +45,14 @@ check_for_updates() {
local remote_url="https://raw.githubusercontent.com/wp-cli/scaffold-command/main/templates/install-wp-tests.sh"
local tmp_script="$TMPDIR/install-wp-tests.sh.latest"

download "$remote_url" "$tmp_script"
if ! download "$remote_url" "$tmp_script"; then
echo -e "${YELLOW}Warning: Failed to download the latest version of the script for update check.${RESET}"
return
fi

if [ ! -f "$tmp_script" ]; then
echo -e "${YELLOW}Warning: Could not download the latest version of the script for update check.${RESET}"
if [ ! -f "$tmp_script" ] || [ ! -s "$tmp_script" ]; then
echo -e "${YELLOW}Warning: Downloaded script is missing or empty, cannot check for updates.${RESET}"
rm -f "$tmp_script"
return
fi

Expand Down
Loading