Skip to content

Commit

Permalink
skip installed extensions in VS Code configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
awojasinski committed Jan 9, 2024
1 parent 84cc2ef commit c0893c3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
20 changes: 12 additions & 8 deletions roles/code/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
- name: Copy VS Code settings file
ansible.builtin.copy:
src: settings.json
dest: "{{ (code_settings_path |
selectattr('os', 'equalto', ansible_facts['os_family']) |
first).path }}/settings.json"
dest: "{{ code_settings_path }}"
mode: "0644"

- name: List VS Code extensions
ansible.builtin.command:
argv:
- code
- --list-extensions
register: code_extensions_list
changed_when: false
no_log: true

- name: Install extensions
ansible.builtin.command:
argv:
Expand All @@ -21,8 +28,5 @@
- "{{ item.id }}"
register: cmd_output
changed_when: cmd_output.rc != 0
with_items:
- {name: Cpp Tools, id: ms-vscode.cpptools}
- {name: EditorConfig Viewer, id: EditorConfig.EditorConfig}
- {name: Git graph, id: mhutchie.git-graph}
- {name: Github themes, id: GitHub.github-vscode-theme}
with_items: "{{ code_extensions }}"
when: not item.id in code_extensions_list.stdout_lines
13 changes: 12 additions & 1 deletion roles/code/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
---
code_settings_path:
code_settings_path_os:
- os: "Darwin"
path: "{{ lookup('ansible.builtin.env', 'HOME') }}/Library/Application\ Support/Code/User"
- os: "Debian"
path: "{{ lookup('ansible.builtin.env', 'HOME') }}/.config/Code/User/"

code_settings_path:
"{{ (code_settings_path_os |
selectattr('os', 'equalto', ansible_facts['os_family']) |
first).path }}/settings.json"

code_extensions:
- {name: Cpp Tools, id: ms-vscode.cpptools}
- {name: EditorConfig Viewer, id: EditorConfig.EditorConfig}
- {name: Git graph, id: mhutchie.git-graph}
- {name: Github themes, id: GitHub.github-vscode-theme}

0 comments on commit c0893c3

Please sign in to comment.