This repository was archived by the owner on May 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
feat(code-server): skip extension if installed #259
Merged
code-asher
merged 7 commits into
coder:main
from
michaelbrewer:feat/skip-already-installed
Jun 17, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f77b145
feat(code-server): skip extension if installed
michaelbrewer 741a8d7
fix: add missing check for use_cached
michaelbrewer 484fc27
feat: check if grep is installed
michaelbrewer 7f40af0
feat(code-server): add use_cached_extensions option
michaelbrewer ccff642
chore: trigger ci
michaelbrewer 48e9367
feat: use --list-extensions
michaelbrewer b7284ed
chore: add print
michaelbrewer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,14 +57,33 @@ if [ ! -f "$CODE_SERVER" ] || [ "${USE_CACHED}" != true ]; then | |
printf "🥳 code-server has been installed in ${INSTALL_PREFIX}\n\n" | ||
fi | ||
|
||
# Get the list of installed extensions... | ||
LIST_EXTENSIONS=$($CODE_SERVER --list-extensions $EXTENSION_ARG) | ||
readarray -t EXTENSIONS_ARRAY <<< "$LIST_EXTENSIONS" | ||
function extension_installed() { | ||
if [ "${USE_CACHED_EXTENSIONS}" != true ]; then | ||
return 1 | ||
fi | ||
for _extension in "$${EXTENSIONS_ARRAY[@]}"; do | ||
code-asher marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if [ "$_extension" == "$1" ]; then | ||
echo "Extension $1 was already installed." | ||
return 0 | ||
fi | ||
done | ||
return 1 | ||
} | ||
|
||
# Install each extension... | ||
IFS=',' read -r -a EXTENSIONLIST <<< "$${EXTENSIONS}" | ||
for extension in "$${EXTENSIONLIST[@]}"; do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @code-asher - see example of why I need to escape the $ |
||
if [ -z "$extension" ]; then | ||
continue | ||
fi | ||
if extension_installed "$extension"; then | ||
continue | ||
fi | ||
printf "🧩 Installing extension $${CODE}$extension$${RESET}...\n" | ||
output=$($CODE_SERVER "$EXTENSION_ARG" --install-extension "$extension") | ||
output=$($CODE_SERVER "$EXTENSION_ARG" --force --install-extension "$extension") | ||
if [ $? -ne 0 ]; then | ||
echo "Failed to install extension: $extension: $output" | ||
exit 1 | ||
|
@@ -86,7 +105,10 @@ if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; 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 | ||
$CODE_SERVER "$EXTENSION_ARG" --install-extension "$extension" | ||
if extension_installed "$extension"; then | ||
continue | ||
fi | ||
$CODE_SERVER "$EXTENSION_ARG" --force --install-extension "$extension" | ||
done | ||
fi | ||
fi | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.