1
0
Fork 0
mirror of https://github.com/ryanccn/flake.git synced 2025-12-06 08:10:43 +01:00

fix(vscode): use full path to CLI and support dry runs

This commit is contained in:
Ryan Cao 2023-09-04 23:06:04 +08:00
parent 43feb86859
commit d8df2278e7
Signed by: ryanccn
SSH key fingerprint: SHA256:NtP/BlVhoQq4xU6BEcZeT8nIPvHntkJ3lIc2yB+F09E

View file

@ -181,13 +181,15 @@ in {
home.activation = {
vscodeExtensions = lib.hm.dag.entryAfter ["writeBoundary"] ''
if ! command -v "code" &> /dev/null; then
code_bin="/usr/local/bin/code"
if ! command -v "$code_bin" &> /dev/null; then
echo "code CLI is not available"
exit 0
fi
declare -A currentExtensions
for extension in $(code --list-extensions); do
for extension in $("$code_bin" --list-extensions); do
currentExtensions["$extension"]=1;
done
@ -198,7 +200,7 @@ in {
(ext: ''
if [[ -z "''${currentExtensions[${ext}]+unset}" ]]; then
echo "installing ${ext}"
code --install-extension ${ext} &> /dev/null
$DRY_RUN_CMD "$code_bin" --install-extension ${ext} &> /dev/null
fi
unset 'currentExtensions[${ext}]'
'')
@ -207,7 +209,7 @@ in {
for ext in "''${!currentExtensions[@]}"; do
echo "uninstalling $ext"
code --uninstall-extension $ext &> /dev/null
$DRY_RUN_CMD "$code_bin" --uninstall-extension $ext &> /dev/null
currentExtensions[$ext]=
done
'';