Skip to content

Commit

Permalink
Refactor the refresh-wp-install-tests.sh script
Browse files Browse the repository at this point in the history
The comment added now includes the source URL, and overall the script removes a fair number of backslashes.

This commit also contains code from @szepeviktor, see #5
  • Loading branch information
stevegrunwell committed Feb 12, 2022
1 parent 5e98405 commit d77daac
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bin/refresh-wp-install-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
#
# Refreshes the bin/install-wp-tests.sh file from source, injecting a comment at the top of the file.

SRC="https://raw.githubusercontent.com/wp-cli/scaffold-command/master/templates/install-wp-tests.sh"
DIR="$( cd "$(dirname "$0")" || exit 1; pwd -P )"
upstream_src='https://raw.githubusercontent.com/wp-cli/scaffold-command/master/templates/install-wp-tests.sh'
bin_dir="$(dirname "${BASH_SOURCE[0]}")"

curl -s "$SRC" \
| sed $'2i\\\n# Notice: This file is pulled from the WP-CLI scaffold command,\\\n# and should not be modified directly.\n' \
> "$DIR/install-wp-tests.sh" \
&& echo -e "\033[0;32mbin/install-wp-tests.sh has been updated to match ${SRC}\033[0;0m"
curl -s "$upstream_src" | sed "2i\\
# Notice: This file is pulled from the WP-CLI scaffold command, and should not be modified directly.\\
#\\
# ${upstream_src}
" > "${bin_dir}/install-wp-tests.sh" || exit 1

printf "\033[0;32m%s %s\033[0;32m\n" 'bin/install-wp-tests.sh has been updated to match' "$upstream_src"

This comment has been minimized.

Copy link
@szepeviktor

szepeviktor Feb 12, 2022

Contributor

printf needs ' single quotes

0 comments on commit d77daac

Please sign in to comment.