Refactor getJuliaVersion to make it testable

This commit is contained in:
Sascha Mann
2019-10-04 00:21:58 +02:00
parent dc7dce0a2d
commit 16c0aaf600
4 changed files with 10 additions and 9 deletions

6
lib/installer.js generated
View File

@@ -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}`;
}