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