Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corretto toolcache folder name fix #26

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions __tests__/distributors/corretto-installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,3 +241,22 @@ describe('getAvailableVersions', () => {
spyGetDownloadArchiveExtension.mockReturnValue(mockedExtension);
};
});

describe('convertVersionToSemver', () => {
it.each([
['12', '12'],
['12.0', '12.0'],
['12.0.2', '12.0.2'],
['12.0.2.1', '12.0.2+1'],
['12.0.2.1.0', '12.0.2+1.0']
])('%s -> %s', (input: string, expected: string) => {
const distribution = new CorrettoDistribution({
version: '12',
architecture: 'x86',
packageType: 'jdk',
checkLatest: false
});
const actual = distribution['convertVersionToSemver'](input);
expect(actual).toBe(expected);
});
});
11 changes: 10 additions & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104208,7 +104208,7 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
.filter(item => item.version == version)
.map(item => {
return {
version: item.correttoVersion,
version: this.convertVersionToSemver(item.correttoVersion),
url: item.downloadLink
};
});
Expand Down Expand Up @@ -104297,6 +104297,15 @@ class CorrettoDistribution extends base_installer_1.JavaBase {
}
return match[1];
}
convertVersionToSemver(version) {
// corretto uses semver-like notation e.g. 17.0.6.10.1
const versionArray = version.split('.');
const mainVersion = versionArray.slice(0, 3).join('.');
if (versionArray.length > 3) {
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
}
return mainVersion;
}
}
exports.CorrettoDistribution = CorrettoDistribution;

Expand Down
13 changes: 12 additions & 1 deletion src/distributions/corretto/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class CorrettoDistribution extends JavaBase {
.filter(item => item.version == version)
.map(item => {
return {
version: item.correttoVersion,
version: this.convertVersionToSemver(item.correttoVersion),
url: item.downloadLink
} as JavaDownloadRelease;
});
Expand Down Expand Up @@ -179,4 +179,15 @@ export class CorrettoDistribution extends JavaBase {
}
return match[1];
}

private convertVersionToSemver(version: string) {
// corretto uses semver-like notation e.g. 17.0.6.10.1
const versionArray = version.split('.');
const mainVersion = versionArray.slice(0, 3).join('.');
if (versionArray.length > 3) {
return `${mainVersion}+${versionArray.slice(3).join('.')}`;
}

return mainVersion;
}
}