Compare commits

...

1 Commits

Author SHA1 Message Date
Danny Kopping
9aefe61d48 fix(vscode-web): apply settings on every workspace start
Previously, settings were only written to settings.json if the file
did not already exist. This meant that template changes to the settings
variable would never be applied to existing workspaces.

Now, Machine settings are always applied on every workspace start,
which is the expected behavior for template-controlled settings.

Fixes: https://github.com/coder/registry/issues/42
2025-12-03 11:31:03 +02:00
2 changed files with 7 additions and 7 deletions

View File

@ -53,7 +53,7 @@ module "vscode-web" {
### Pre-configure Settings ### Pre-configure Settings
Configure VS Code's [settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settings-json-file) file: Configure VS Code's [Machine settings.json](https://code.visualstudio.com/docs/getstarted/settings#_settings-json-file) file. These settings are applied on every workspace start, ensuring template-defined settings are always enforced:
```tf ```tf
module "vscode-web" { module "vscode-web" {

View File

@ -28,12 +28,12 @@ run_vscode_web() {
"$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" "$DISABLE_TRUST_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 & "$VSCODE_WEB" serve-local "$EXTENSION_ARG" "$SERVER_BASE_PATH_ARG" "$DISABLE_TRUST_ARG" --port "${PORT}" --host 127.0.0.1 --accept-server-license-terms --without-connection-token --telemetry-level "${TELEMETRY_LEVEL}" > "${LOG_PATH}" 2>&1 &
} }
# Check if the settings file exists... # Apply/overwrite template-based settings on every start
if [ ! -f ~/.vscode-server/data/Machine/settings.json ]; then # Machine settings are always overwritten to apply template changes.
echo "⚙️ Creating settings file..." # See: https://github.com/coder/registry/issues/42
mkdir -p ~/.vscode-server/data/Machine echo "⚙️ Applying VS Code settings..."
echo "${SETTINGS}" > ~/.vscode-server/data/Machine/settings.json mkdir -p ~/.vscode-server/data/Machine
fi echo "${SETTINGS}" > ~/.vscode-server/data/Machine/settings.json
# Check if vscode-server is already installed for offline or cached mode # Check if vscode-server is already installed for offline or cached mode
if [ -f "$VSCODE_WEB" ]; then if [ -f "$VSCODE_WEB" ]; then