mirror of
https://github.com/nix-community/nix-direnv.git
synced 2025-11-08 11:36:11 +01:00
27 lines
623 B
Python
27 lines
623 B
Python
import logging
|
|
import shlex
|
|
import subprocess
|
|
from pathlib import Path
|
|
from typing import IO, Any
|
|
|
|
_FILE = None | int | IO[Any]
|
|
_DIR = None | Path | str
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
def run(
|
|
cmd: list[str],
|
|
text: bool = True,
|
|
check: bool = True,
|
|
cwd: _DIR = None,
|
|
stderr: _FILE = None,
|
|
stdout: _FILE = None,
|
|
env: dict[str, str] | None = None,
|
|
) -> subprocess.CompletedProcess:
|
|
if cwd is not None:
|
|
log.debug(f"cd {cwd}")
|
|
log.debug(f"$ {shlex.join(cmd)}")
|
|
return subprocess.run(
|
|
cmd, text=text, check=check, cwd=cwd, stderr=stderr, stdout=stdout, env=env
|
|
)
|