Skip to content

Commit 658e2a0

Browse files
committed
Release 1.0.1
fix(check-update): Fixed check_update function
1 parent 66fd8c6 commit 658e2a0

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0
1+
1.0.1

lib/functions.sh

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -86,33 +86,31 @@ _checkroot () {
8686

8787
# -- check_for_updates
8888
help_cmd[check-update]="Check for updates to wpst"
89-
function tool_check-update () {
90-
local script_name="$1"
91-
local github_url="$2"
92-
89+
function wpst_check_update () {
9390
# Get the local version from the VERSION file
94-
local local_version
91+
local LOCAL_VERSION
9592
if [[ -f "VERSION" ]]; then
96-
local_version=$(cat "VERSION")
93+
LOCAL_VERSION=$(cat "VERSION")
9794
else
9895
echo "ERROR: VERSION file not found."
9996
return 1
10097
fi
10198

10299
# Get the remote version from GitHub
103-
local remote_version
104-
remote_version=$(curl -sSL "$github_url/VERSION")
105-
if [[ -z "$remote_version" ]]; then
100+
local REMOTE_VERSION
101+
REMOTE_VERSION=$(curl -sSL "$GITHUB_URL/VERSION")
102+
if [[ -z "$REMOTE_VERSION" ]]; then
106103
echo "ERROR: Failed to retrieve remote version from GitHub."
107104
return 1
108105
fi
109106

110107
# Compare local and remote versions
111-
if [[ "$local_version" == "$remote_version" ]]; then
112-
echo "Your script ($script_name) is up to date."
108+
if [[ "$LOCAL_VERSION" == "$REMOTE_VERSION" ]]; then
109+
echo "Up to date. Local:$LOCAL_VERSION - Latest: $REMOTE_VERSION"
110+
# Check if local version is higher than remote version
111+
elif [[ "$LOCAL_VERSION" > "$REMOTE_VERSION" ]]; then
112+
echo "Local version ($LOCAL_VERSION) is higher than latest version ($REMOTE_VERSION)."
113113
else
114-
echo "Your script ($script_name) is out of date."
115-
echo "Local version: $local_version"
116-
echo "Remote version: $remote_version"
114+
echo "Out of date. Local:$LOCAL_VERSION - Latest: $REMOTE_VERSION"
117115
fi
118116
}

wpst.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
SCRIPT_DIR="$( dirname "${BASH_SOURCE[0]}" )"
77
WPST_VERSION="$(cat ${SCRIPT_DIR}/VERSION)"
88
SCRIPT_NAME="wpst"
9+
GITHUB_URL="https://raw.githubusercontent.com/managingwp/wp-shelltools/main/"
910

1011
source $SCRIPT_DIR/lib/functions.sh # Core Functions
1112
source $SCRIPT_DIR/lib/functions-gp.sh # GP Functions
@@ -77,8 +78,8 @@ elif [[ $ACTION = "ajaxlog" ]]; then
7778

7879
elif [[ $ACTION = gp-* ]]; then
7980
cmd_$@
80-
elif [[ $ACTION = "check-updates" ]]; then
81-
wpst_check_updates
81+
elif [[ $ACTION = "check-update" ]]; then
82+
wpst_check_update
8283
else
8384
usage
8485
exit 1

0 commit comments

Comments
 (0)