@@ -57,14 +57,33 @@ if [ ! -f "$CODE_SERVER" ] || [ "${USE_CACHED}" != true ]; then
5757 printf " 🥳 code-server has been installed in ${INSTALL_PREFIX} \n\n"
5858fi
5959
60+ # Get the list of installed extensions...
61+ LIST_EXTENSIONS=$( $CODE_SERVER --list-extensions $EXTENSION_ARG )
62+ readarray -t EXTENSIONS_ARRAY <<< " $LIST_EXTENSIONS"
63+ function extension_installed() {
64+ if [ " ${USE_CACHED_EXTENSIONS} " != true ]; then
65+ return 1
66+ fi
67+ for _extension in " $$ {EXTENSIONS_ARRAY[@]}" ; do
68+ if [ " $_extension " == " $1 " ]; then
69+ echo " Extension $1 was already installed."
70+ return 0
71+ fi
72+ done
73+ return 1
74+ }
75+
6076# Install each extension...
6177IFS=' ,' read -r -a EXTENSIONLIST <<< " $${EXTENSIONS}"
6278for extension in " $$ {EXTENSIONLIST[@]}" ; do
6379 if [ -z " $extension " ]; then
6480 continue
6581 fi
82+ if extension_installed " $extension " ; then
83+ continue
84+ fi
6685 printf " 🧩 Installing extension $$ {CODE}$extension $$ {RESET}...\n"
67- output=$( $CODE_SERVER " $EXTENSION_ARG " --install-extension " $extension " )
86+ output=$( $CODE_SERVER " $EXTENSION_ARG " --force -- install-extension " $extension " )
6887 if [ $? -ne 0 ]; then
6988 echo " Failed to install extension: $extension : $output "
7089 exit 1
@@ -86,7 +105,10 @@ if [ "${AUTO_INSTALL_EXTENSIONS}" = true ]; then
86105 printf " 🧩 Installing extensions from %s/.vscode/extensions.json...\n" " $WORKSPACE_DIR "
87106 extensions=$( jq -r ' .recommendations[]' " $WORKSPACE_DIR " /.vscode/extensions.json)
88107 for extension in $extensions ; do
89- $CODE_SERVER " $EXTENSION_ARG " --install-extension " $extension "
108+ if extension_installed " $extension " ; then
109+ continue
110+ fi
111+ $CODE_SERVER " $EXTENSION_ARG " --force --install-extension " $extension "
90112 done
91113 fi
92114fi
0 commit comments