Skip to content

Commit

Permalink
Fix package installation logic, and use something else to test for a …
Browse files Browse the repository at this point in the history
…valid installation...
  • Loading branch information
fubarhouse committed Dec 8, 2017
1 parent 0ac1ae2 commit 5f9b838
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
15 changes: 9 additions & 6 deletions tasks/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
shell: "yarn global remove {{ item.name }}@{{ item.version | default('') }} --PREFIX={{ yarn_global_path }}"
failed_when: false
with_items:
- "{{ yarn_global_packages }}"
- "{{ yarn_global_packages }}"
changed_when: false
when: yarn_clean_install == true

- name: "Yarn | Get list of globally installed packages"
shell: "yarn global ls"
shell: "yarn global list"
register: yarn_global_ls
failed_when: false
changed_when: false

- name: "Yarn | Add globally installed packages"
shell: "yarn global add {{ item.name }}@{{ item.version | default('') }} --PREFIX={{ yarn_global_path }}"
when: '"{{ item.name }}@{{ item.version | default() }}" not in "{{ yarn_global_ls.stdout }}"'
when:
- item.name + '@' + item.version not in yarn_global_ls.stdout
with_items:
- "{{ yarn_global_packages }}"
- "{{ yarn_global_packages }}"

- name: "Yarn | Upgrade installed packages"
shell: "yarn global upgrade {{ item.name }} --PREFIX={{ yarn_global_path }}"
when: '"{{ item.name }}@{{ item.version | default() }}" in "{{ yarn_global_ls.stdout }}" and "{{ item.upgrade }}" is defined and item.upgrade == true'
when:
- item.upgrade is defined
- item.upgrade|bool == true
with_items:
- "{{ yarn_global_packages }}"
- "{{ yarn_global_packages }}"
1 change: 1 addition & 0 deletions tasks/yarn-Darwin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
6 changes: 3 additions & 3 deletions tasks/yarn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@
- 'yarn_clean_install == true'

- name: "Yarn | Check for installation"
shell: yarn --help
shell: which yarn
register: yarn_result
changed_when: '"Usage" not in yarn_result.stdout and "Yarn requires Node" not in yarn_result.stdout and "is not supported, please use Node.js" not in yarn_result.stdout'
changed_when: '"yarn" not in yarn_result.stdout'
changed_when: false
failed_when: false

- name: "Yarn | Register existing installation status"
set_fact:
yarn_install_state: true
changed_when: false
when: '"Usage" in yarn_result.stdout or "Yarn requires Node" in yarn_result.stdout or "is not supported, please use Node.js" in yarn_result.stdout'
when: '"yarn" in yarn_result.stdout'

- name: "Yarn | Register existing installation status"
set_fact:
Expand Down

0 comments on commit 5f9b838

Please sign in to comment.