Adrià Vilanova Martínez | 166f67f | 2024-09-29 12:32:38 +0200 | [diff] [blame] | 1 | - name: Ensure we know what version of node to install |
| 2 | assert: |
| 3 | that: node_version is defined |
| 4 | |
Adrià Vilanova Martínez | 8fe5213 | 2024-09-29 12:43:09 +0200 | [diff] [blame] | 5 | - name: Check installed Node version |
Adrià Vilanova Martínez | 16b9f46 | 2024-05-04 01:08:33 +0200 | [diff] [blame] | 6 | command: node --version |
Adrià Vilanova Martínez | 8fe5213 | 2024-09-29 12:43:09 +0200 | [diff] [blame] | 7 | register: node_installed_version |
| 8 | failed_when: false |
Adrià Vilanova Martínez | 16b9f46 | 2024-05-04 01:08:33 +0200 | [diff] [blame] | 9 | |
Adrià Vilanova Martínez | 8fe5213 | 2024-09-29 12:43:09 +0200 | [diff] [blame] | 10 | - name: Install NodeJS when it is not installed with the required version |
| 11 | include_tasks: install-nodejs.yaml |
| 12 | when: |
| 13 | - node_installed_version.rc != 0 or |
| 14 | (node_version | string | trim) != |
| 15 | (node_installed_version.stdout |
| 16 | | regex_replace('^v(?P<majorVersion>[^.]+).*$', '\\g<majorVersion>') |
| 17 | | trim) |