From 4259d72e25d0d91502d7b39dbc6253a8e2c13bc7 Mon Sep 17 00:00:00 2001 From: Ivan Zosimov Date: Wed, 20 Sep 2023 11:48:35 +0200 Subject: [PATCH] chore: refactor code --- dist/setup/index.js | 12 +++--------- src/distributions/dragonwell/installer.ts | 14 ++++---------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 8f995588..4e99c8ed 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -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': diff --git a/src/distributions/dragonwell/installer.ts b/src/distributions/dragonwell/installer.ts index 57b102d6..11ed4c25 100644 --- a/src/distributions/dragonwell/installer.ts +++ b/src/distributions/dragonwell/installer.ts @@ -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':