Get CLI path for E2E tests. Uses COPILOT_CLI_PATH env var if set, otherwise node_modules CLI.
()
| 20 | |
| 21 | |
| 22 | def get_cli_path_for_tests() -> str: |
| 23 | """Get CLI path for E2E tests. |
| 24 | |
| 25 | Uses COPILOT_CLI_PATH env var if set, otherwise node_modules CLI. |
| 26 | """ |
| 27 | env_path = os.environ.get("COPILOT_CLI_PATH") |
| 28 | if env_path and Path(env_path).exists(): |
| 29 | return str(Path(env_path).resolve()) |
| 30 | |
| 31 | # Look for CLI in sibling nodejs directory's node_modules. As of CLI 1.0.64-1 |
| 32 | # the @github/copilot package is a thin loader; the runnable index.js ships in |
| 33 | # the installed platform package (e.g. @github/copilot-linux-x64). |
| 34 | base_path = Path(__file__).parents[3] |
| 35 | github_modules = base_path / "nodejs" / "node_modules" / "@github" |
| 36 | for platform_pkg in sorted(github_modules.glob("copilot-*")): |
| 37 | candidate = platform_pkg / "index.js" |
| 38 | if candidate.exists(): |
| 39 | return str(candidate.resolve()) |
| 40 | |
| 41 | raise RuntimeError("CLI not found for tests. Run 'npm install' in the nodejs directory.") |
| 42 | |
| 43 | |
| 44 | CLI_PATH = get_cli_path_for_tests() |