mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-21 21:14:17 +02:00
Handle missing npx.cmd fallback on Windows 🤖 Generated with GPT-5.2-Codex (#3416)
This commit is contained in:
parent
0b97aca02a
commit
dcaeef0f3d
2 changed files with 18 additions and 1 deletions
|
|
@ -54,7 +54,7 @@ def _get_npx_command():
|
|||
try:
|
||||
subprocess.run([cmd, "--version"], check=True, capture_output=True)
|
||||
return cmd
|
||||
except subprocess.CalledProcessError:
|
||||
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||
continue
|
||||
return None
|
||||
return "npx" # On Unix-like systems, just use npx
|
||||
|
|
|
|||
|
|
@ -440,6 +440,23 @@ class TestWindowsSpecific:
|
|||
assert result == "npx.exe"
|
||||
assert mock_run.call_count == 2
|
||||
|
||||
@patch("subprocess.run")
|
||||
def test_get_npx_command_windows_cmd_missing(self, mock_run):
|
||||
"""Test npx command detection continues when npx.cmd is missing."""
|
||||
from fastmcp.cli.cli import _get_npx_command
|
||||
|
||||
with patch("sys.platform", "win32"):
|
||||
# Missing npx.cmd should not abort detection
|
||||
mock_run.side_effect = [
|
||||
FileNotFoundError("npx.cmd not found"),
|
||||
Mock(returncode=0),
|
||||
]
|
||||
|
||||
result = _get_npx_command()
|
||||
|
||||
assert result == "npx.exe"
|
||||
assert mock_run.call_count == 2
|
||||
|
||||
@patch("subprocess.run")
|
||||
def test_get_npx_command_windows_fallback(self, mock_run):
|
||||
"""Test npx command detection on Windows with plain npx."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue