fix fnm version check (#2014)

This commit is contained in:
Thomas Brandého 2023-10-23 17:45:55 +02:00 committed by GitHub
parent 490ae40a40
commit d00425276d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -247,13 +247,13 @@ def output_system_info():
if system != "Windows":
dependencies.extend(
[
f"[FNM {constants.Fnm.VERSION} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]",
f"[FNM {prerequisites.get_fnm_version()} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]",
f"[Bun {prerequisites.get_bun_version()} (Expected: {constants.Bun.VERSION}) (PATH: {config.bun_path})]",
],
)
else:
dependencies.append(
f"[FNM {constants.Fnm.VERSION} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]",
f"[FNM {prerequisites.get_fnm_version()} (Expected: {constants.Fnm.VERSION}) (PATH: {constants.Fnm.EXE})]",
)
if system == "Linux":

View File

@ -60,6 +60,19 @@ def get_node_version() -> version.Version | None:
return None
def get_fnm_version() -> version.Version | None:
"""Get the version of fnm.
Returns:
The version of FNM.
"""
try:
result = processes.new_process([constants.Fnm.EXE, "--version"], run=True)
return version.parse(result.stdout.split(" ")[1]) # type: ignore
except (FileNotFoundError, TypeError):
return None
def get_bun_version() -> version.Version | None:
"""Get the version of bun.