From ae2ec9551157a3bcb4ed5c75cf640550aec1bb3f Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Mon, 12 Feb 2024 13:44:26 +0100 Subject: [PATCH] feat(*): improve platform detection --- pongo.sh | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/pongo.sh b/pongo.sh index ca009daa..c7dfdcb7 100755 --- a/pongo.sh +++ b/pongo.sh @@ -76,15 +76,27 @@ function globals { unset WINDOWS_SLASH unset WINPTY_PREFIX - local platform - platform=$(uname -s) - if [ "${platform:0:5}" == "MINGW" ]; then - # Windows requires an extra / in docker command so //bin/bash + unset PONGO_PLATFORM + if [ "$(uname -s)" == "Darwin" ]; then + # all Apple platforms + export PONGO_PLATFORM="APPLE" + elif uname -s | grep -q "MINGW"; then + # Git Bash for Windows + # Msys (not supported!) + export PONGO_PLATFORM="WINDOWS" + # Windows/MinGW requires an extra / in docker command so //bin/bash # https://www.reddit.com/r/docker/comments/734arg/cant_figure_out_how_to_bash_into_docker_container/ WINDOWS_SLASH="/" - # for terminal output we passthrough winpty - WINPTY_PREFIX=winpty - fi; + if winpty --help > /dev/null; then + # for terminal output we passthrough winpty + WINPTY_PREFIX="winpty" + fi + elif grep -q WSL < /proc/version; then + # WSL and WSL2 + export PONGO_PLATFORM="WINDOWS" + else + export PONGO_PLATFORM="LINUX" + fi # when running CI do we have the required secrets available? (used for EE only) # secrets are unavailable for PR's from outside the organization (untrusted)