Skip to content

Commit

Permalink
Fix semver extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
nirinchev committed Feb 27, 2024
1 parent fc0cd56 commit cd3efc6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions run-ios-simulator/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7495,14 +7495,13 @@ function getNewestRuntime(runtimes, os) {
}
function isRuntimeNewer(first, second) {
const extractVersion = (runtime) => {
if (semver.valid(runtime)) {
return runtime;
}
const extractedSemver = runtime.split(" ").pop();
if (!semver.valid(extractedSemver)) {
let extractedVersion = runtime.split(" ").pop();
const components = extractedVersion.split(".").length;
extractedVersion = extractedVersion.concat(...Array.from({ length: 3 - components }, _ => ".0"));
if (!semver.valid(extractedVersion)) {
throw new Error(`Couldn't extract version for runtime ${runtime}`);
}
return extractedSemver;
return extractedVersion;
};
return semver.gt(extractVersion(first), extractVersion(second));
}
Expand Down
11 changes: 5 additions & 6 deletions run-ios-simulator/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,15 @@ function getNewestRuntime(runtimes: string, os: string): { runtime: string; runt

function isRuntimeNewer(first: string, second: string): boolean {
const extractVersion = (runtime: string): string => {
if (semver.valid(runtime)) {
return runtime;
}
let extractedVersion = runtime.split(" ").pop()!;
const components = extractedVersion.split(".").length;
extractedVersion = extractedVersion.concat(...Array.from({ length: 3 - components}, _ => ".0"));

const extractedSemver = runtime.split(" ").pop();
if (!semver.valid(extractedSemver)) {
if (!semver.valid(extractedVersion)) {
throw new Error(`Couldn't extract version for runtime ${runtime}`);
}

return extractedSemver!;
return extractedVersion;
};

return semver.gt(extractVersion(first), extractVersion(second));
Expand Down

0 comments on commit cd3efc6

Please sign in to comment.