From bad6bd879069ab5d4adc9b296f55c72f7fdc92d3 Mon Sep 17 00:00:00 2001 From: Zachary Cutlip Date: Tue, 29 Mar 2022 20:09:22 -0700 Subject: [PATCH] Remove python dependency in cli on macOS --- build/mac/hyper | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/build/mac/hyper b/build/mac/hyper index 3f17302c..8f53707a 100755 --- a/build/mac/hyper +++ b/build/mac/hyper @@ -1,8 +1,27 @@ #!/usr/bin/env bash -# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.17.0/resources/darwin/bin/code.sh +# Deeply inspired by https://github.com/Microsoft/vscode/blob/1.65.2/resources/darwin/bin/code.sh -function realpath() { /usr/bin/python -c "import os,sys; print(os.path.realpath(sys.argv[1]))" "$0"; } -CONTENTS="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")" +# TODO: bash is deprecated on macOS and will be removed. +# Port this to /bin/sh or /bin/zsh + +function app_realpath() { + SOURCE=$1 + while [ -h "$SOURCE" ]; do + DIR=$(dirname "$SOURCE") + SOURCE=$(readlink "$SOURCE") + [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE + done + SOURCE_DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" + echo "${SOURCE_DIR%%"${SOURCE_DIR#*.app}"}" +} + +APP_PATH="$(app_realpath "${BASH_SOURCE[0]}")" +if [ -z "$APP_PATH" ]; then + echo "Unable to determine app path from symlink : ${BASH_SOURCE[0]}" + exit 1 +fi + +CONTENTS="$APP_PATH/Contents" ELECTRON="$CONTENTS/MacOS/Hyper" CLI="$CONTENTS/Resources/bin/cli.js" ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@"