[cr145] Adds RunNodeRaw to brave_node.

Chromium change:

https://source.chromium.org/chromium/chromium/src/+/f364a8e21e616f7f3b6befe67cec36f14a4d2494

commit f364a8e21e616f7f3b6befe67cec36f14a4d2494
Author: Fumitoshi Ukai <ukai@google.com>
Date:   Tue Dec 2 21:46:11 2025 -0800

    node.py: print stderr/stdout/exit status, attempt 2.

    previous attempt e24157c11d87344aeeddb2b0f6353bf2947082e3
    failed since eslint captures json output in RuntimeError message.

    instead of parsing RuntimeError message of node.py,
    introduce RunNodeRaw in node.Run and get (exitcode,stdout,stderr)
    in JsChecker.RunEsLintCheck.
    also introduce cwd to pass node.Run, instead of os.chdir before
    calling node.Run.

    Cq-Include-Trybots: luci.chromium.try:linux-presubmit,win-presubmit
    Bug: 461602362
This commit is contained in:
Max Karolinskiy
2026-01-29 13:40:37 -05:00
parent ef03a318c8
commit 1686700f74
2 changed files with 10 additions and 5 deletions
+9 -4
View File
@@ -15,7 +15,7 @@ def PathInNodeModules(*args):
return os.path.join(NODE_MODULES, *args)
def RunNode(cmd_parts, include_command_in_error=True):
def RunNodeRaw(cmd_parts):
cmd = ['node'] + cmd_parts
process = subprocess.Popen(cmd,
cwd=os.getcwd(),
@@ -23,11 +23,16 @@ def RunNode(cmd_parts, include_command_in_error=True):
stderr=subprocess.PIPE,
universal_newlines=True)
stdout, stderr = process.communicate()
return process.returncode, stdout, stderr
if process.returncode != 0:
def RunNode(cmd_parts, include_command_in_error=True):
returncode, stdout, stderr = RunNodeRaw(cmd_parts)
if returncode != 0:
err = stderr if len(stderr) > 0 else stdout
raise RuntimeError(f"Command '{' '.join(cmd)}' failed\n{err}"
if include_command_in_error else err)
raise RuntimeError(
f"Command '{' '.join(['node'] + cmd_parts)}' failed\n{err}"
if include_command_in_error else err)
return stdout