@@ -5,31 +5,32 @@ set -eu
55# Runs code-server with the bundled node binary.
66
77_realpath () {
8- if [ " $( uname) " = " Linux" ]; then
9- readlink -f " $1 "
10- return
11- fi
12-
13- # See https://github.com/cdr/code-server/issues/1537
14- if [ " $( uname) " = " Darwin" ]; then
15- script=" $1 "
16- if [ -L " $script " ]; then
17- while [ -L " $script " ]; do
18- # We recursively read the symlink, which may be relative from $script.
19- script=" $( readlink " $script " ) "
20- cd " $( dirname " $script " ) "
21- done
22- else
23- cd " $( dirname " $script " ) "
8+ # See https://github.com/cdr/code-server/issues/1537 on why no realpath or readlink -f.
9+
10+ script=" $1 "
11+ cd " $( dirname " $script " ) "
12+
13+ while [ -L " $( basename " $script " ) " ]; do
14+ if [ -L " ./node" ] && [ -L " ./code-server" ] &&
15+ [ -f " package.json" ] &&
16+ cat package.json | grep -q ' ^ "name": "code-server",$' ; then
17+ echo " ***** Please use the script in bin/code-server instead!" >&2
18+ echo " ***** This script will soon be removed!" >&2
19+ echo " ***** See the release notes at https://github.com/cdr/code-server/releases/tag/v3.4.0" >&2
2420 fi
2521
26- echo " $PWD /$( basename " $script " ) "
27- return
28- fi
22+ script=" $( readlink " $( basename " $script " ) " ) "
23+ cd " $( dirname " $script " ) "
24+ done
25+
26+ echo " $PWD /$( basename " $script " ) "
27+ }
2928
30- echo " Unsupported OS $( uname) " >&2
31- exit 1
29+ root () {
30+ script=" $( _realpath " $0 " ) "
31+ bin_dir=" $( dirname " $script " ) "
32+ echo " $( dirname " $bin_dir " ) "
3233}
3334
34- ROOT=" $( dirname " $( dirname " $( _realpath " $0 " ) " ) " ) "
35+ ROOT=" $( root ) "
3536exec " $ROOT /lib/node" " $ROOT " " $@ "
0 commit comments