use absolute() instead of resolve()

This commit is contained in:
Lendemor 2025-01-21 16:09:02 +01:00
parent b12d1d6e82
commit a9acc6da7c
3 changed files with 5 additions and 8 deletions

View File

@ -174,7 +174,7 @@ def get_node_path() -> str | None:
return str(node_path) return str(node_path)
def get_npm_path() -> str | None: def get_npm_path() -> Path | None:
"""Get npm binary path. """Get npm binary path.
Returns: Returns:
@ -183,8 +183,8 @@ def get_npm_path() -> str | None:
npm_path = Path(constants.Node.NPM_PATH) npm_path = Path(constants.Node.NPM_PATH)
if use_system_node() or not npm_path.exists(): if use_system_node() or not npm_path.exists():
system_npm_path = which("npm") system_npm_path = which("npm")
return str(system_npm_path) if system_npm_path else None npm_path = Path(system_npm_path).parent.resolve() if system_npm_path else None
return str(npm_path) return npm_path.absolute() if npm_path else None
def update_json_file(file_path: str | Path, update_dict: dict[str, int | str]): def update_json_file(file_path: str | Path, update_dict: dict[str, int | str]):

View File

@ -243,9 +243,7 @@ def get_package_manager(on_failure_return_none: bool = False) -> str | None:
""" """
npm_path = path_ops.get_npm_path() npm_path = path_ops.get_npm_path()
if npm_path is not None: if npm_path is not None:
if constants.IS_WINDOWS: return str(npm_path)
return str(Path(npm_path).resolve())
return npm_path
if on_failure_return_none: if on_failure_return_none:
return None return None
raise FileNotFoundError("NPM not found. You may need to run `reflex init`.") raise FileNotFoundError("NPM not found. You may need to run `reflex init`.")

View File

@ -9,7 +9,6 @@ import os
import signal import signal
import subprocess import subprocess
from concurrent import futures from concurrent import futures
from pathlib import Path
from typing import Callable, Generator, List, Optional, Tuple, Union from typing import Callable, Generator, List, Optional, Tuple, Union
import psutil import psutil
@ -368,7 +367,7 @@ def get_command_with_loglevel(command: list[str]) -> list[str]:
The updated command list The updated command list
""" """
npm_path = path_ops.get_npm_path() npm_path = path_ops.get_npm_path()
npm_path = str(Path(npm_path).resolve()) if npm_path else npm_path npm_path = str(npm_path) if npm_path else None
if command[0] == npm_path: if command[0] == npm_path:
return [*command, "--loglevel", "silly"] return [*command, "--loglevel", "silly"]