2
2
3
3
BOLD=' \033[0;1m'
4
4
EXTENSIONS=(" ${EXTENSIONS} " )
5
+ VSCODE_WEB=" ${INSTALL_PREFIX} /bin/code-server"
6
+
7
+ # Set extension directory
8
+ EXTENSION_ARG=" "
9
+ if [ -n " ${EXTENSIONS_DIR} " ]; then
10
+ EXTENSION_ARG=" --extensions-dir=${EXTENSIONS_DIR} "
11
+ fi
12
+
13
+ run_vscode_web () {
14
+ echo " 👷 Running $VSCODE_WEB serve-local $EXTENSION_ARG --port ${PORT} --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..."
15
+ echo " Check logs at ${LOG_PATH} !"
16
+ " $VSCODE_WEB " serve-local " $EXTENSION_ARG " --port " ${PORT} " --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level " ${TELEMETRY_LEVEL} " > " ${LOG_PATH} " 2>&1 &
17
+ }
18
+
19
+ # Check if the settings file exists...
20
+ if [ ! -f ~ /.vscode-server/data/Machine/settings.json ]; then
21
+ echo " ⚙️ Creating settings file..."
22
+ mkdir -p ~ /.vscode-server/data/Machine
23
+ echo " ${SETTINGS} " > ~ /.vscode-server/data/Machine/settings.json
24
+ fi
25
+
26
+ # Check if vscode-server is already installed for offline or cached mode
27
+ if [ -f " $VSCODE_WEB " ]; then
28
+ if [ " ${OFFLINE} " = true ] || [ " ${USE_CACHED} " = true ]; then
29
+ echo " 🥳 Found a copy of VS Code Web"
30
+ run_vscode_web
31
+ exit 0
32
+ fi
33
+ fi
34
+ # Offline mode always expects a copy of vscode-server to be present
35
+ if [ " ${OFFLINE} " = true ]; then
36
+ echo " Failed to find a copy of VS Code Web"
37
+ exit 1
38
+ fi
5
39
6
40
# Create install prefix
7
41
mkdir -p ${INSTALL_PREFIX}
@@ -26,9 +60,7 @@ if [ $? -ne 0 ]; then
26
60
echo " Failed to install Microsoft Visual Studio Code Server: $output "
27
61
exit 1
28
62
fi
29
- printf " $$ {BOLD}Microsoft Visual Studio Code Server has been installed.\n"
30
-
31
- VSCODE_SERVER=" ${INSTALL_PREFIX} /bin/code-server"
63
+ printf " $$ {BOLD}VS Code Web has been installed.\n"
32
64
33
65
# Install each extension...
34
66
IFS=' ,' read -r -a EXTENSIONLIST <<< " $${EXTENSIONS}"
@@ -37,20 +69,31 @@ for extension in "$${EXTENSIONLIST[@]}"; do
37
69
continue
38
70
fi
39
71
printf " 🧩 Installing extension $$ {CODE}$extension $$ {RESET}...\n"
40
- output=$( $VSCODE_SERVER --install-extension " $extension " --force)
72
+ output=$( $VSCODE_WEB " $EXTENSION_ARG " --install-extension " $extension " --force)
41
73
if [ $? -ne 0 ]; then
42
74
echo " Failed to install extension: $extension : $output "
43
75
exit 1
44
76
fi
45
77
done
46
78
47
- # Check if the settings file exists...
48
- if [ ! -f ~ /.vscode-server/data/Machine/settings.json ]; then
49
- echo " ⚙️ Creating settings file..."
50
- mkdir -p ~ /.vscode-server/data/Machine
51
- echo " ${SETTINGS} " > ~ /.vscode-server/data/Machine/settings.json
79
+ if [ " ${AUTO_INSTALL_EXTENSIONS} " = true ]; then
80
+ if ! command -v jq > /dev/null; then
81
+ echo " jq is required to install extensions from a workspace file."
82
+ exit 0
83
+ fi
84
+
85
+ WORKSPACE_DIR=" $HOME "
86
+ if [ -n " ${FOLDER} " ]; then
87
+ WORKSPACE_DIR=" ${FOLDER} "
88
+ fi
89
+
90
+ if [ -f " $WORKSPACE_DIR /.vscode/extensions.json" ]; then
91
+ printf " 🧩 Installing extensions from %s/.vscode/extensions.json...\n" " $WORKSPACE_DIR "
92
+ extensions=$( jq -r ' .recommendations[]' " $WORKSPACE_DIR " /.vscode/extensions.json)
93
+ for extension in $extensions ; do
94
+ $VSCODE_WEB " $EXTENSION_ARG " --install-extension " $extension " --force
95
+ done
96
+ fi
52
97
fi
53
98
54
- echo " 👷 Running ${INSTALL_PREFIX} /bin/code-server serve-local --port ${PORT} --host 127.0.0.1 --accept-server-license-terms serve-local --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..."
55
- echo " Check logs at ${LOG_PATH} !"
56
- " ${INSTALL_PREFIX} /bin/code-server" serve-local --port " ${PORT} " --host 127.0.0.1 --accept-server-license-terms serve-local --without-connection-token --telemetry-level " ${TELEMETRY_LEVEL} " > " ${LOG_PATH} " 2>&1 &
99
+ run_vscode_web
0 commit comments