Skip to content

Commit

Permalink
fix(md5): check avaiable and platform fix
Browse files Browse the repository at this point in the history
BSD uses 'md5', not 'md5sum'
  • Loading branch information
Tieske committed Dec 20, 2024
1 parent 000cb4e commit f3d44df
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@

## Unreleased...

* Fix: check for `md5` availability in platform indepedent way.
Removes need to install coreutils on Mac.
[#642](https://github.com/Kong/kong-pongo/pull/642).

---

## 2.15.0 released 17-Dec-2024
Expand Down
17 changes: 16 additions & 1 deletion pongo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function globals {
fi

# create unique projectID based on file-path (on the host machine)
PROJECT_ID=$(echo -n "$PONGO_WD" | md5sum)
PROJECT_ID=$(echo -n "$PONGO_WD" | $MD5_COMMAND )
PROJECT_ID="${PROJECT_ID:0:8}"

PROJECT_NAME_PREFIX="pongo-"
Expand Down Expand Up @@ -232,6 +232,21 @@ function check_tools {
missing=true
fi

# Detect the MD5 command
if command -v md5sum &> /dev/null; then
# Unix
MD5_COMMAND="md5sum"
elif command -v gmd5sum &> /dev/null; then
# GNU
MD5_COMMAND="gmd5sum"
elif command -v md5 &> /dev/null; then
# BSD/Mac
MD5_COMMAND="md5"
else
>&2 echo "'md5sum', 'gmd5sum', and 'md5' commands not found, please install anyone of them, and make it available in the path."
missing=true
fi

if [[ "$missing" == "true" ]]; then
>&2 echo -e "\033[0;31m[pongo-ERROR] the above dependencies are missing, install and retry.\033[0m"
exit 1
Expand Down

0 comments on commit f3d44df

Please sign in to comment.