mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 09:39:39 +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:
parent
a267743095
commit
3b9756d9b1
Notes:
github-actions[bot]
2025-06-11 17:56:22 +00:00
Author: https://github.com/ADKaster
Commit: 3b9756d9b1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5047
1 changed files with 3 additions and 1 deletions
|
@ -6,6 +6,7 @@ import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Union
|
from typing import Union
|
||||||
|
|
||||||
|
@ -15,13 +16,14 @@ def run_command(
|
||||||
input: Union[str, None] = None,
|
input: Union[str, None] = None,
|
||||||
return_output: bool = False,
|
return_output: bool = False,
|
||||||
exit_on_failure: bool = False,
|
exit_on_failure: bool = False,
|
||||||
|
cwd: Union[Path, None] = None,
|
||||||
) -> Optional[str]:
|
) -> Optional[str]:
|
||||||
stdin = subprocess.PIPE if type(input) is str else None
|
stdin = subprocess.PIPE if type(input) is str else None
|
||||||
stdout = subprocess.PIPE if return_output else None
|
stdout = subprocess.PIPE if return_output else None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# FIXME: For Windows, set the working directory so DLLs are found.
|
# 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)
|
(output, _) = process.communicate(input=input)
|
||||||
|
|
||||||
if process.returncode != 0:
|
if process.returncode != 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue