Przeglądaj źródła

fix fnm version check (#2014)

Thomas Brandého 1 rok temu
rodzic
commit
d00425276d
2 zmienionych plików z 15 dodań i 2 usunięć
  1. 2 2
      reflex/utils/exec.py
  2. 13 0
      reflex/utils/prerequisites.py

+ 2 - 2
reflex/utils/exec.py

@@ -247,13 +247,13 @@ def output_system_info():
     if system != "Windows":
     if system != "Windows":
         dependencies.extend(
         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})]",
                 f"[Bun {prerequisites.get_bun_version()} (Expected: {constants.Bun.VERSION}) (PATH: {config.bun_path})]",
             ],
             ],
         )
         )
     else:
     else:
         dependencies.append(
         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":
     if system == "Linux":

+ 13 - 0
reflex/utils/prerequisites.py

@@ -60,6 +60,19 @@ def get_node_version() -> version.Version | None:
         return 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:
 def get_bun_version() -> version.Version | None:
     """Get the version of bun.
     """Get the version of bun.