@@ -18,35 +18,30 @@ vscode_version() {
18
18
}
19
19
20
20
os () {
21
- local os
22
- os=$( uname | tr ' [:upper:]' ' [:lower:]' )
23
- if [[ $os == " linux" ]]; then
24
- # Alpine's ldd doesn't have a version flag but if you use an invalid flag
25
- # (like --version) it outputs the version to stderr and exits with 1.
26
- local ldd_output
27
- ldd_output=$( ldd --version 2>&1 || true)
28
- if echo " $ldd_output " | grep -iq musl; then
29
- os=" alpine"
30
- fi
31
- elif [[ $os == " darwin" ]]; then
32
- os=" macos"
33
- fi
34
- echo " $os "
21
+ osname=$( uname | tr ' [:upper:]' ' [:lower:]' )
22
+ case $osname in
23
+ linux)
24
+ # Alpine's ldd doesn't have a version flag but if you use an invalid flag
25
+ # (like --version) it outputs the version to stderr and exits with 1.
26
+ # TODO: Better to check /etc/os-release; see ../install.sh.
27
+ ldd_output=$( ldd --version 2>&1 || true)
28
+ if echo " $ldd_output " | grep -iq musl; then
29
+ osname=" alpine"
30
+ fi
31
+ ;;
32
+ darwin) osname=" macos" ;;
33
+ cygwin* | mingw* ) osname=" windows" ;;
34
+ esac
35
+ echo " $osname "
35
36
}
36
37
37
38
arch () {
38
39
cpu=" $( uname -m) "
39
40
case " $cpu " in
40
- aarch64)
41
- echo arm64
42
- ;;
43
- x86_64 | amd64)
44
- echo amd64
45
- ;;
46
- * )
47
- echo " $cpu "
48
- ;;
41
+ aarch64) cpu=arm64 ;;
42
+ x86_64 | amd64) cpu=amd64 ;;
49
43
esac
44
+ echo " $cpu "
50
45
}
51
46
52
47
# Grabs the most recent ci.yaml github workflow run that was triggered from the
@@ -105,6 +100,18 @@ export OS
105
100
# Defaults to release
106
101
RELEASE_PATH=" ${RELEASE_PATH-release} "
107
102
103
+ # Create a symlink at $2 pointing to $1 on any platform. Anything that
104
+ # currently exists at $2 will be deleted.
105
+ symlink () {
106
+ source=" $1 "
107
+ dest=" $2 "
108
+ rm -rf " $dest "
109
+ case $OS in
110
+ windows) mklink /J " $dest " " $source " ;;
111
+ * ) ln -s " $source " " $dest " ;;
112
+ esac
113
+ }
114
+
108
115
# VS Code bundles some modules into an asar which is an archive format that
109
116
# works like tar. It then seems to get unpacked into node_modules.asar.
110
117
#
@@ -113,12 +120,19 @@ RELEASE_PATH="${RELEASE_PATH-release}"
113
120
# Code itself but also extensions will look specifically in this directory for
114
121
# files (like the ripgrep binary or the oniguruma wasm).
115
122
symlink_asar () {
116
- rm -rf node_modules.asar
117
- if [ " ${WINDIR-} " ]; then
118
- # mklink takes the link name first.
119
- mklink /J node_modules.asar node_modules
120
- else
121
- # ln takes the link name second.
122
- ln -s node_modules node_modules.asar
123
- fi
123
+ symlink node_modules node_modules.asar
124
+ }
125
+
126
+ # Symlink the correct bin script from $source to $dest depending on the
127
+ # platform. The extension will be .cmd for Windows otherwise it will be
128
+ # whatever is in $3 if it exists.
129
+ symlink_bin_script () {
130
+ source=" $1 "
131
+ dest=" $2 "
132
+ ext=" ${1-} "
133
+ case $OS in
134
+ windows) symlink " $source .cmd" " $dest .cmd" ;;
135
+ darwin | macos) symlink " $source -darwin.sh" " $dest$ext " ;;
136
+ * ) symlink " $source -linux.sh" " $dest$ext " ;;
137
+ esac
124
138
}
0 commit comments