format & build

This commit is contained in:
Evgenii Korolevskii 2022-12-08 10:46:41 +01:00
parent 0143667d3d
commit f68f88a1bc
4 changed files with 74 additions and 57 deletions

View file

@ -28,4 +28,4 @@ export const MVN_TOOLCHAINS_FILE = 'toolchains.xml';
export const INPUT_MVN_TOOLCHAIN_ID = 'mvn-toolchain-id';
export const INPUT_MVN_TOOLCHAIN_VENDOR = 'mvn-toolchain-vendor';
export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto']
export const DISTRIBUTIONS_ONLY_MAJOR_VERSION = ['corretto'];

View file

@ -47,13 +47,13 @@ async function run() {
.readFileSync(versionFile)
.toString()
.trim();
const version = getVersionFromFileContent(content, distributionName)
const version = getVersionFromFileContent(content, distributionName);
if (!version) {
throw new Error(`No supported version was found in file ${versionFile}`);
}
await installVersion(version as string, installerInputsOptions);
}
@ -128,7 +128,7 @@ function getVersionFromFileContent(content: string, distributionName: string): s
? (content.match(javaVersionRegExp)?.groups?.version as string)
: '';
if (!fileContent) {
return null
return null;
}
const tentativeVersion = avoidOldNotation(fileContent);
@ -137,7 +137,7 @@ function getVersionFromFileContent(content: string, distributionName: string): s
: semver.coerce(tentativeVersion);
if (!version) {
return null
return null;
}
if (constants.DISTRIBUTIONS_ONLY_MAJOR_VERSION.includes(distributionName)) {
@ -150,4 +150,4 @@ function getVersionFromFileContent(content: string, distributionName: string): s
// By convention, action expects version 8 in the format `8.*` instead of `1.8`
function avoidOldNotation(content: string): string {
return content.substring(0, 2) === '1.' ? content.substring(2) : content;
}
}