From f8061412c643771c542a78ed91b47da3d5b4a4d3 Mon Sep 17 00:00:00 2001 From: Gil Tene Date: Sat, 21 Dec 2019 19:51:32 -0800 Subject: [PATCH] Add support for matching -ea version formats This will support specifying EA versions in the following format examples. E.g.: 14-ea 14.0.0-ea 14.0.0-ea.28 Notes: - For the last form above, which is needed for requesting a specific ea build, we must only add '.x' if there are less than 3 dots in the version, hence the change from != 3 to < 3 - The prior parsing logic for e.g. 14.0.0-ea "spelling" will ignore precedence between build numbers in the form of e.g. 14.0.0-ea+b27 vs. 14.0.0-ea+b27 (so it will end up with the earliest rather than the latest ea build in the cdn), and does not allow specifying an ea build number (it will match 14.0.0-ea+b29 to a cdn 14.0.0-ea+b2). The new logic [copupled with the CDN populating EA builds in the form 14.0.0-ea.28) will resolve that. --- src/installer.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/installer.ts b/src/installer.ts index f05171fb..f49c1c95 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -266,12 +266,21 @@ function normalizeVersion(version: string): string { } } - // Add trailing .x if it is missing - if (version.split('.').length != 3) { + if (version.endsWith('-ea')) { + // convert e.g. 14-ea to 14.0.0-ea + if (version.indexOf('.') == -1) { + version = version.slice(0, version.length - 3) + '.0.0-ea'; + } + // match anything in -ea.X (semver won't do .x matching on pre-release versions) + if (version[0] >= '0' && version[0] <= '9') { + version = '>=' + version; + } + } else if (version.split('.').length < 3) { + // For non-ea versions, add trailing .x if it is missing if (version[version.length - 1] != 'x') { version = version + '.x'; } } - + return version; }