Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coder-server extension should wait in the the project folder exists #279

Open
michaelbrewer opened this issue Jul 26, 2024 · 0 comments
Open
Labels
good first issue Good for newcomers

Comments

@michaelbrewer
Copy link
Contributor

In some cases auto_install_extensions won't if the workspace has not been checkout yet.

Ideally coder should provide a method to wait on a dependent task from completing.

A work around is to poll for the folder to be created before running the install like so.

if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; then
  if ! command -v jq > /dev/null; then
    echo "jq is required to install extensions from a workspace file."
    exit 0
  fi

  WORKSPACE_DIR="$HOME"
  if [ -n "${FOLDER}" ]; then
    WORKSPACE_DIR="${FOLDER}"
  fi

  TIMEOUT=10
  INTERVAL=1
  ELAPSED=0
  while [ $ELAPSED -lt $TIMEOUT ]; do
    if [ -d "$WORKSPACE_DIR" ]; then
      echo "Directory $WORKSPACE_DIR exists."
      break
    fi
    sleep $INTERVAL
    ELAPSED=$((ELAPSED + INTERVAL))
  done

  if [ -f "$WORKSPACE_DIR/.vscode/extensions.json" ]; then
    printf "🧩 Installing extensions from %s/.vscode/extensions.json...\n" "$WORKSPACE_DIR"
    extensions=$(jq -r '.recommendations[]' "$WORKSPACE_DIR"/.vscode/extensions.json)
    for extension in $extensions; do
      if extension_installed "$extension"; then
        continue
      fi
      $CODE_SERVER "$EXTENSION_ARG" --force --install-extension "$extension"
    done
  fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants