22
33BOLD=' \033[0;1m'
44EXTENSIONS=(" ${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
539
640# Create install prefix
741mkdir -p ${INSTALL_PREFIX}
@@ -26,9 +60,7 @@ if [ $? -ne 0 ]; then
2660 echo " Failed to install Microsoft Visual Studio Code Server: $output "
2761 exit 1
2862fi
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"
3264
3365# Install each extension...
3466IFS=' ,' read -r -a EXTENSIONLIST <<< " $${EXTENSIONS}"
@@ -37,20 +69,31 @@ for extension in "$${EXTENSIONLIST[@]}"; do
3769 continue
3870 fi
3971 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)
4173 if [ $? -ne 0 ]; then
4274 echo " Failed to install extension: $extension : $output "
4375 exit 1
4476 fi
4577done
4678
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
5297fi
5398
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