(version: string, parseOpt: ParseParam)
| 93 | } |
| 94 | |
| 95 | function parseVersion(version: string, parseOpt: ParseParam): Version | undefined { |
| 96 | const matches = version.match(/v?(?<major>\d+)(?:.(?<minor>\d+).(?<patch>\d+)(?:-(?<tag>\w+)(?:-(?<build>[a-zA-Z0-9]+)(?:-(?<date>\d+))?)?)?)?/) |
| 97 | |
| 98 | if (!matches?.groups) { |
| 99 | parseOpt.errorCallback('version', version, parseOpt.primaryKey); |
| 100 | return undefined |
| 101 | } |
| 102 | |
| 103 | const minor = tryParseNumber(matches.groups.minor) |
| 104 | const patch = tryParseNumber(matches.groups.patch) |
| 105 | const tag = matches.groups.tag |
| 106 | const build = matches.groups.build |
| 107 | const date = matches.groups.date |
| 108 | |
| 109 | return { |
| 110 | major: parseInt(matches.groups.major), |
| 111 | ...minor !== undefined && { minor }, |
| 112 | ...patch !== undefined && { patch }, |
| 113 | ...tag && { tag }, |
| 114 | ...build && { build }, |
| 115 | ...date && { date }, |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | function parseOs(os: string, parseOpt: ParseParam): OperatingSytem | undefined { |
| 120 | const match = matchAll(os, /(linux|windows|darwin|x86_64|x64|amd64)/g) |
no test coverage detected