mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 19:46:11 +01:00
The files are not executable, tests should only be run via `pytest`, and some of them were incorrectly python2.
23 lines
586 B
Python
23 lines
586 B
Python
import subprocess
|
|
from pathlib import Path
|
|
from typing import IO, Any, List, Optional, Union
|
|
|
|
_FILE = Union[None, int, IO[Any]]
|
|
_DIR = Union[None, Path, str]
|
|
|
|
|
|
def run(
|
|
cmd: List[str],
|
|
text: bool = True,
|
|
check: bool = True,
|
|
cwd: _DIR = None,
|
|
stderr: _FILE = None,
|
|
stdout: _FILE = None,
|
|
env: Optional[dict[str, str]] = None,
|
|
) -> subprocess.CompletedProcess:
|
|
if cwd is not None:
|
|
print(f"cd {cwd}")
|
|
print("$ " + " ".join(cmd))
|
|
return subprocess.run(
|
|
cmd, text=text, check=check, cwd=cwd, stderr=stderr, stdout=stdout, env=env
|
|
)
|