()
| 188 | } |
| 189 | |
| 190 | async function getLatestVersion() { |
| 191 | try { |
| 192 | const res = await httpGet( |
| 193 | `https://registry.npmjs.org/${packageName}/latest`, |
| 194 | ) |
| 195 | |
| 196 | if (res.statusCode !== 200) return null |
| 197 | |
| 198 | const body = await streamToString(res) |
| 199 | const packageData = JSON.parse(body) |
| 200 | |
| 201 | return packageData.version || null |
| 202 | } catch (error) { |
| 203 | return null |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | function streamToString(stream) { |
| 208 | return new Promise((resolve, reject) => { |
no test coverage detected