fix: relax and coerce the found pip version

This commit is contained in:
Amin Yahyaabadi 2023-07-15 15:23:17 -07:00
parent 9292ace132
commit 1f24044002
12 changed files with 33 additions and 38 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -93,7 +93,7 @@ export async function getBinVersion(file: string, versionRegex: RegExp = default
const execout = await getExecOutput(file, ["--version"])
const version_output = execout.stdout || execout.stderr || ""
const version = version_output.trim().match(versionRegex)?.[1]
return version
return semverCoerce(version) ?? undefined
} catch (e) {
console.error(e)
return undefined
@ -107,12 +107,7 @@ export async function isBinUptoDate(
versionRegex: RegExp = defaultVersionRegex
) {
const givenVersion = await getBinVersion(givenFile, versionRegex)
if (
typeof givenVersion === "string" &&
typeof targetVersion === "string" &&
givenVersion !== "" &&
targetVersion !== ""
) {
if (givenVersion !== undefined && targetVersion !== "") {
return semverCompare(givenVersion, targetVersion) !== -1
} else {
// assume given version is old

View File

@ -31,7 +31,7 @@ export const DefaultVersions: Record<string, string | undefined> = {
}
export const MinVersions: Record<string, string | undefined> = {
pip: "22.3.1",
pip: "22.2.0",
python: "3.7.9",
}