mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-05 01:10:24 +00:00
Meta: Add optional cwd argument to run_command helper
This just passes it through to subprocess.Popen, so it can be used to run commands in a specific directory if needed.
This commit is contained in:
committed by
Andrew Kaster
parent
a267743095
commit
3b9756d9b1
Notes:
github-actions[bot]
2025-06-11 17:56:22 +00:00
Author: https://github.com/ADKaster Commit: https://github.com/LadybirdBrowser/ladybird/commit/3b9756d9b1b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5047
@@ -6,6 +6,7 @@ import signal
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
from typing import Union
|
||||
|
||||
@@ -15,13 +16,14 @@ def run_command(
|
||||
input: Union[str, None] = None,
|
||||
return_output: bool = False,
|
||||
exit_on_failure: bool = False,
|
||||
cwd: Union[Path, None] = None,
|
||||
) -> Optional[str]:
|
||||
stdin = subprocess.PIPE if type(input) is str else None
|
||||
stdout = subprocess.PIPE if return_output else None
|
||||
|
||||
try:
|
||||
# FIXME: For Windows, set the working directory so DLLs are found.
|
||||
with subprocess.Popen(command, stdin=stdin, stdout=stdout, text=True) as process:
|
||||
with subprocess.Popen(command, stdin=stdin, stdout=stdout, text=True, cwd=cwd) as process:
|
||||
(output, _) = process.communicate(input=input)
|
||||
|
||||
if process.returncode != 0:
|
||||
|
||||
Reference in New Issue
Block a user