This repository was archived by the owner on May 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,12 @@ variable "extensions_dir" {
101101 default = " "
102102}
103103
104+ variable "auto_install_extensions" {
105+ type = bool
106+ description = " Automatically install recommended extensions when code-server starts."
107+ default = false
108+ }
109+
104110resource "coder_script" "code-server" {
105111 agent_id = var. agent_id
106112 display_name = " code-server"
@@ -117,6 +123,8 @@ resource "coder_script" "code-server" {
117123 OFFLINE : var.offline,
118124 USE_CACHED : var.use_cached,
119125 EXTENSIONS_DIR : var.extensions_dir,
126+ FOLDER : var.folder,
127+ AUTO_INSTALL_EXTENSIONS : var.auto_install_extensions,
120128 })
121129 run_on_start = true
122130
Original file line number Diff line number Diff line change @@ -70,4 +70,24 @@ for extension in "$${EXTENSIONLIST[@]}"; do
7070 fi
7171done
7272
73+ if [ " ${AUTO_INSTALL_EXTENSIONS} " = true ]; then
74+ if ! command -v jq > /dev/null; then
75+ echo " jq is required to install extensions from a workspace file."
76+ exit 0
77+ fi
78+
79+ WORKSPACE_DIR=" $HOME "
80+ if [ -n " ${FOLDER} " ]; then
81+ WORKSPACE_DIR=" ${FOLDER} "
82+ fi
83+
84+ if [ -f " $WORKSPACE_DIR /.vscode/extensions.json" ]; then
85+ printf " 🧩 Installing extensions from %s/.vscode/extensions.json...\n" " $WORKSPACE_DIR "
86+ extensions=$( jq -r ' .recommendations[]' " $WORKSPACE_DIR " /.vscode/extensions.json)
87+ for extension in $extensions ; do
88+ $CODE_SERVER " $EXTENSION_ARG " --install-extension " $extension "
89+ done
90+ fi
91+ fi
92+
7393run_code_server
You can’t perform that action at this time.
0 commit comments