(name: string)
| 5 | /(?<=^v?|\sv?)(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*)(?:\.(?:0|[1-9]\d*|[\da-z-]*[a-z-][\da-z-]*))*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?(\.windows.[0-9]+)?(?=$|\s)/gi |
| 6 | |
| 7 | export const getVersion = async (name: string): Promise<{ version: string | null; error: Error | null }> => { |
| 8 | try { |
| 9 | const { stdout, stderr } = await exec({ command: `${name} --version` }) |
| 10 | if (!stderr) { |
| 11 | const match = stdout.match(semverRegex) |
| 12 | if (match) { |
| 13 | const parsedVersion = match[0].split('.').slice(0, 3).join('.') |
| 14 | return { version: parsedVersion, error: null } |
| 15 | } |
| 16 | } |
| 17 | return { version: null, error: null } |
| 18 | } catch (error: any) { |
| 19 | return { version: null, error } |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | export const compareVersions = async (currentVersion: string, expectedVersion: string): Promise<never | boolean> => { |
| 24 | // see node-semver docs: https://github.com/npm/node-semver |
no test coverage detected