* Extracts the latest node version from a JSON object containing version info * * @param {!Object} distributionsJson * @return {string}
(distributionsJson)
| 171 | * @return {string} |
| 172 | */ |
| 173 | function getNodeLatestLtsVersion(distributionsJson) { |
| 174 | if (distributionsJson) { |
| 175 | // Versions are in descending order, so the first match is the latest lts. |
| 176 | return distributionsJson.find(function (distribution) { |
| 177 | return ( |
| 178 | distribution.hasOwnProperty('version') && |
| 179 | distribution.hasOwnProperty('lts') && |
| 180 | distribution.lts |
| 181 | ); |
| 182 | }).version; |
| 183 | } else { |
| 184 | return ''; |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * If npm is being run, log its version and proceed with the install. |