diff --git a/CHANGELOG.md b/CHANGELOG.md index a4c6f014..b9e2c10b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/pongo.sh b/pongo.sh index 713587fd..325b47b6 100755 --- a/pongo.sh +++ b/pongo.sh @@ -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-" @@ -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