Run a shell command and return output. Args: cmd: Command to run as list of strings. cwd: Working directory for command. Returns: Command output as string. Raises: subprocess.CalledProcessError: If command fails.
(cmd: list[str], cwd: Path | None = None)
| 65 | |
| 66 | |
| 67 | def run_command(cmd: list[str], cwd: Path | None = None) -> str: |
| 68 | """Run a shell command and return output. |
| 69 | |
| 70 | Args: |
| 71 | cmd: Command to run as list of strings. |
| 72 | cwd: Working directory for command. |
| 73 | |
| 74 | Returns: |
| 75 | Command output as string. |
| 76 | |
| 77 | Raises: |
| 78 | subprocess.CalledProcessError: If command fails. |
| 79 | """ |
| 80 | result = subprocess.run( # noqa: S603 |
| 81 | cmd, |
| 82 | cwd=cwd, |
| 83 | capture_output=True, |
| 84 | text=True, |
| 85 | check=True, |
| 86 | ) |
| 87 | return result.stdout.strip() |
| 88 | |
| 89 | |
| 90 | def check_gh_installed() -> None: |
no test coverage detected