- name: Build aur packages
  when: closed_source_vscode
  register: buildaur
  become_user: "{{ build_user.name }}"
  command: "aurutils-sync --no-view {{ item }}"
  args:
    creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*"
  loop:
    - visual-studio-code-bin

- name: Update cache
  when: closed_source_vscode and buildaur.changed
  pacman:
    name: []
    state: present
    update_cache: true

- name: Install packages
  when: closed_source_vscode
  package:
    name:
      - visual-studio-code-bin
    state: present

- name: Install packages
  when: not closed_source_vscode
  package:
    name:
      - code
    state: present
