chore: refactor code

This commit is contained in:
Ivan Zosimov 2023-09-20 11:48:35 +02:00
parent 3fd8616c89
commit 4259d72e25
2 changed files with 7 additions and 19 deletions

12
dist/setup/index.js vendored
View File

@ -102731,8 +102731,10 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
if (jdkVersion === 'latest') {
continue;
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
if (jdkVersion.split('.').length > 3) {
jdkVersion = this.transformToSemver(jdkVersion);
jdkVersion = util_1.convertVersionToSemver(jdkVersion);
}
for (const edition in archMap) {
eligibleVersions.push({
@ -102760,14 +102762,6 @@ class DragonwellDistribution extends base_installer_1.JavaBase {
});
return sortedVersions.reverse();
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
transformToSemver(version) {
const splits = version.split('.');
const versionMainPart = splits.slice(0, 3).join('.');
const versionBuildPart = splits.slice(3).join('.');
return `${versionMainPart}+${versionBuildPart}`;
}
getPlatformOption() {
switch (process.platform) {
case 'win32':

View File

@ -7,6 +7,7 @@ import path from 'path';
import {JavaBase} from '../base-installer';
import {
convertVersionToSemver,
extractJdkFile,
getDownloadArchiveExtension,
getGitHubHttpHeaders,
@ -146,8 +147,10 @@ export class DragonwellDistribution extends JavaBase {
continue;
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
if (jdkVersion.split('.').length > 3) {
jdkVersion = this.transformToSemver(jdkVersion);
jdkVersion = convertVersionToSemver(jdkVersion);
}
for (const edition in archMap) {
@ -182,15 +185,6 @@ export class DragonwellDistribution extends JavaBase {
return sortedVersions.reverse();
}
// Some version of Dragonwell JDK are numerated with help of non-semver notation (more then 3 digits).
// Common practice is to transform excess digits to the so-called semver build part, which is prefixed with the plus sign, to be able to operate with them using semver tools.
private transformToSemver(version: string) {
const splits = version.split('.');
const versionMainPart = splits.slice(0, 3).join('.');
const versionBuildPart = splits.slice(3).join('.');
return `${versionMainPart}+${versionBuildPart}`;
}
private getPlatformOption(): string {
switch (process.platform) {
case 'win32':