mirror of
https://github.com/nix-community/nix-direnv.git
synced 2024-09-11 11:35:54 +03:00
28 lines
623 B
Python
28 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
|
|
)
|