Resolve the Lighthouse CLI command. Returns: The command prefix used to invoke Lighthouse.
()
| 691 | |
| 692 | |
| 693 | def get_lighthouse_command() -> list[str]: |
| 694 | """Resolve the Lighthouse CLI command. |
| 695 | |
| 696 | Returns: |
| 697 | The command prefix used to invoke Lighthouse. |
| 698 | """ |
| 699 | if command := os.environ.get(LIGHTHOUSE_COMMAND_ENV_VAR): |
| 700 | return shlex.split(command) |
| 701 | if shutil.which("lighthouse") is not None: |
| 702 | return ["lighthouse"] |
| 703 | if shutil.which("npx") is not None: |
| 704 | return ["npx", "--yes", LIGHTHOUSE_CLI_PACKAGE] |
| 705 | if shutil.which("pnpx") is not None: |
| 706 | return ["pnpx", LIGHTHOUSE_CLI_PACKAGE] |
| 707 | pytest.skip( |
| 708 | "Lighthouse CLI is unavailable. " |
| 709 | "Install `lighthouse`, make `npx` or `pnpx` available, " |
| 710 | f"or set {LIGHTHOUSE_COMMAND_ENV_VAR}." |
| 711 | ) |
| 712 | |
| 713 | |
| 714 | def _format_subprocess_output(output: str | bytes | None) -> str: |
no test coverage detected