diff --git a/hermes_cli/doctor.py b/hermes_cli/doctor.py index ae0477d103d..a279306a94f 100644 --- a/hermes_cli/doctor.py +++ b/hermes_cli/doctor.py @@ -1469,7 +1469,7 @@ def run_doctor(args): # For workspace-scoped audits run from PROJECT_ROOT the # node_modules check must use the workspace root; standalone dirs # (whatsapp-bridge) check their own node_modules. - check_dir = npm_dir if audit_extra else npm_dir + check_dir = PROJECT_ROOT if audit_extra else npm_dir if not (check_dir / "node_modules").exists(): continue try: diff --git a/tests/hermes_cli/test_web_ui_build.py b/tests/hermes_cli/test_web_ui_build.py index 1f76e2a7cb5..06a453277cd 100644 --- a/tests/hermes_cli/test_web_ui_build.py +++ b/tests/hermes_cli/test_web_ui_build.py @@ -140,6 +140,19 @@ class TestBuildWebUISkipsWhenFresh: assert kwargs["encoding"] == "utf-8" assert kwargs["errors"] == "replace" + def test_npm_install_uses_workspace_web_scope(self, tmp_path): + web_dir, _ = _make_web_dir(tmp_path) + mock_cp = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="") + build_ok = __import__("subprocess").CompletedProcess([], 0, stdout="", stderr="") + with patch("hermes_cli.main.shutil.which", return_value="/usr/bin/npm"), \ + patch("hermes_cli.main.subprocess.run", return_value=mock_cp) as mock_run, \ + patch("hermes_cli.main._run_with_idle_timeout", return_value=build_ok): + result = _build_web_ui(web_dir) + assert result is True + install_cmd = mock_run.call_args[0][0] + assert "--workspace" in install_cmd + assert install_cmd[install_cmd.index("--workspace") + 1] == "web" + def test_web_build_uses_idle_timeout_helper(self, tmp_path): """npm run build now goes through _run_with_idle_timeout (issue #33788).