File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,40 @@ download() {
3030 fi
3131}
3232
33+ check_for_updates () {
34+ local remote_url=" https://raw.githubusercontent.com/wp-cli/scaffold-command/main/templates/install-wp-tests.sh"
35+ local tmp_script=" $TMPDIR /install-wp-tests.sh.latest"
36+
37+ download " $remote_url " " $tmp_script "
38+
39+ if [ ! -f " $tmp_script " ]; then
40+ echo " Warning: Could not download the latest version of the script for update check."
41+ return
42+ fi
43+
44+ local local_hash=" "
45+ local remote_hash=" "
46+
47+ if command -v shasum > /dev/null; then
48+ local_hash=$( shasum -a 256 " $0 " | awk ' {print $1}' )
49+ remote_hash=$( shasum -a 256 " $tmp_script " | awk ' {print $1}' )
50+ elif command -v sha256sum > /dev/null; then
51+ local_hash=$( sha256sum " $0 " | awk ' {print $1}' )
52+ remote_hash=$( sha256sum " $tmp_script " | awk ' {print $1}' )
53+ else
54+ echo " Warning: Could not find shasum or sha256sum to check for script updates."
55+ rm " $tmp_script "
56+ return
57+ fi
58+
59+ rm " $tmp_script "
60+
61+ if [ " $local_hash " != " $remote_hash " ]; then
62+ echo " Warning: A newer version of this script is available at $remote_url "
63+ fi
64+ }
65+ check_for_updates
66+
3367if [[ $WP_VERSION =~ ^[0-9]+\. [0-9]+\- (beta| RC)[0-9]+$ ]]; then
3468 WP_BRANCH=${WP_VERSION% \- * }
3569 WP_TESTS_TAG=" branches/$WP_BRANCH "
You can’t perform that action at this time.
0 commit comments