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
42 lines
1.3 KiB
Python
Executable File
42 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2022 The Brave Authors. All rights reserved.
|
|
# This Source Code Form is subject to the terms of the Mozilla Public
|
|
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
# You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
|
|
NODE_MODULES = os.path.join(os.path.dirname(__file__), '..', 'node_modules')
|
|
|
|
|
|
def PathInNodeModules(*args):
|
|
return os.path.join(NODE_MODULES, *args)
|
|
|
|
|
|
def RunNodeRaw(cmd_parts):
|
|
cmd = ['node'] + cmd_parts
|
|
process = subprocess.Popen(cmd,
|
|
cwd=os.getcwd(),
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
universal_newlines=True)
|
|
stdout, stderr = process.communicate()
|
|
return process.returncode, stdout, stderr
|
|
|
|
|
|
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(['node'] + cmd_parts)}' failed\n{err}"
|
|
if include_command_in_error else err)
|
|
|
|
return stdout
|
|
|
|
|
|
if __name__ == '__main__':
|
|
RunNode(sys.argv[1:])
|