From 401f08db6391c0f4cb6f357bc0684335459c65a9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 22 Apr 2020 17:45:53 -0400 Subject: [PATCH] Fix code-server.sh script on macOS --- ci/code-server.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ci/code-server.sh b/ci/code-server.sh index cd76cc162..0d28736a8 100755 --- a/ci/code-server.sh +++ b/ci/code-server.sh @@ -1,6 +1,18 @@ #!/usr/bin/env sh -# code-server.sh -- Run code-server with the bundled Node binary. +# Runs code-server with the bundled Node binary. -dir="$(dirname "$(readlink -f "$0" || realpath "$0")")" +# More complicated than readlink -f or realpath to support macOS. +# See https://github.com/cdr/code-server/issues/1537 +get_installation_dir() { + # We read the symlink, which may be relative from $0. + dst="$(readlink "$0")" + # We cd into the $0 directory. + cd "$(dirname "$0")" + # Now we can cd into the dst directory. + cd "$(dirname "$dst")" + # Finally we use pwd -P to print the absolute path of the directory of $dst. + pwd -P +} +dir=$(get_installation_dir) exec "$dir/node" "$dir/out/node/entry.js" "$@"