-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
35 lines (29 loc) · 1.17 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
# Check if the extensions.txt file exists
if [ ! -f extensions.txt ]; then
echo "extensions.txt file not found!"
exit 1
fi
# Get the list of installed extensions
installed_extensions=$(code --list-extensions)
# Function to check if an extension is installed
is_extension_installed() {
echo "$installed_extensions" | grep -q "$1"
}
# Read extensions from the file and filter out the ones that are already installed
extensions_to_install=()
while IFS= read -r extension || [ -n "$extension" ]; do
if is_extension_installed "$extension"; then
echo "Extension $extension is already installed, but will be updated if needed."
extensions_to_install+=("$extension")
else
extensions_to_install+=("$extension")
fi
done < extensions.txt
# Install extensions in parallel using xargs with the --force flag
if [ ${#extensions_to_install[@]} -gt 0 ]; then
printf "%s\n" "${extensions_to_install[@]}" | xargs -n 1 -P 4 -I {} sh -c 'echo "Installing or updating {}..."; code --install-extension {} --force || echo "Failed to install {}"'
else
echo "All extensions are already installed and up-to-date."
fi
echo "All extensions processed."