mirror of
https://github.com/julia-actions/setup-julia.git
synced 2026-02-16 21:16:53 +08:00
Refactor getJuliaVersion to make it testable
This commit is contained in:
6
lib/installer.js
generated
6
lib/installer.js
generated
@@ -53,15 +53,15 @@ function getJuliaReleases() {
|
||||
});
|
||||
});
|
||||
}
|
||||
function getJuliaVersion(versionInput) {
|
||||
exports.getJuliaReleases = getJuliaReleases;
|
||||
function getJuliaVersion(availableReleases, versionInput) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (semver.valid(versionInput) == versionInput) {
|
||||
// versionInput is a valid version, use it directly
|
||||
return versionInput;
|
||||
}
|
||||
// Use the highest available version that matches versionInput
|
||||
const releases = yield getJuliaReleases();
|
||||
let version = semver.maxSatisfying(releases, versionInput);
|
||||
let version = semver.maxSatisfying(availableReleases, versionInput);
|
||||
if (version == null) {
|
||||
throw `Could not find a Julia version that matches ${versionInput}`;
|
||||
}
|
||||
|
||||
3
lib/setup-julia.js
generated
3
lib/setup-julia.js
generated
@@ -25,7 +25,8 @@ function run() {
|
||||
try {
|
||||
const versionInput = core.getInput('version');
|
||||
const arch = core.getInput('arch');
|
||||
const version = yield installer.getJuliaVersion(versionInput);
|
||||
const availableReleases = yield installer.getJuliaReleases();
|
||||
const version = yield installer.getJuliaVersion(availableReleases, versionInput);
|
||||
core.debug(`selected Julia version: ${arch}/${version}`);
|
||||
// Search in cache
|
||||
let juliaPath;
|
||||
|
||||
Reference in New Issue
Block a user