From 3edd66d1b030969c0ed0e383b68f185883fd1874 Mon Sep 17 00:00:00 2001 From: Plamen Totev Date: Sun, 12 Apr 2020 18:30:31 +0300 Subject: [PATCH] Add 'latest' as alias for version 'x' While it is possible to specify that you want the latest JDK version by using semver X-Ranges (like 'x' for example), 'latest' is more readable as explicitly states the intention. --- README.md | 2 ++ src/installer.ts | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index c7f492b3..7c0e379b 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ Examples of version specifications that the java-version parameter will accept: e.g. ```8.0.x, >11.0.3, >=13.0.1, <8.0.212``` + e.g. ```latest``` (same as ```x```) + - An early access (EA) Java version e.g. ```14-ea, 15-ea``` diff --git a/src/installer.ts b/src/installer.ts index cce8fa3d..e34393d4 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -271,6 +271,12 @@ function getDownloadInfo( } function normalizeVersion(version: string): string { + // 'latest' means the most recent of any JDK version + // semver won't match pre-release versions + if (version === 'latest') { + version = 'x'; + } + if (version.slice(0, 2) === '1.') { // Trim leading 1. for versions like 1.8 version = version.slice(2);