Skip to content

Commit 8608ae2

Browse files
authored
Merge pull request #1546 from cdr/readlink-mac
Fix code-server.sh script on macOS
2 parents caa299b + 401f08d commit 8608ae2

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

ci/code-server.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
#!/usr/bin/env sh
2-
# code-server.sh -- Run code-server with the bundled Node binary.
2+
# Runs code-server with the bundled Node binary.
33

4-
dir="$(dirname "$(readlink -f "$0" || realpath "$0")")"
4+
# More complicated than readlink -f or realpath to support macOS.
5+
# See https://github.com/cdr/code-server/issues/1537
6+
get_installation_dir() {
7+
# We read the symlink, which may be relative from $0.
8+
dst="$(readlink "$0")"
9+
# We cd into the $0 directory.
10+
cd "$(dirname "$0")"
11+
# Now we can cd into the dst directory.
12+
cd "$(dirname "$dst")"
13+
# Finally we use pwd -P to print the absolute path of the directory of $dst.
14+
pwd -P
15+
}
516

17+
dir=$(get_installation_dir)
618
exec "$dir/node" "$dir/out/node/entry.js" "$@"

0 commit comments

Comments
 (0)