From 0cbb83a5ec51069042c32c3412c4a37d3c56e6eb Mon Sep 17 00:00:00 2001 From: Tim van der Lippe Date: Tue, 12 May 2020 11:34:06 +0100 Subject: [PATCH] Allow node.py to run node scripts If third_party/node/node.py is executed as a regular script, it will consequently run the Node script with the node version that is synced with gclient sync. DISABLE_THIRD_PARTY_CHECK=Node Python fix R=liviurau@chromium.org Bug: 1074325 Change-Id: I738dc3de5dabdef349f90dfc972acd99f139c027 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2194873 Reviewed-by: Liviu Rau Commit-Queue: Tim van der Lippe --- PRESUBMIT.py | 2 +- package.json | 2 +- third_party/node/node.py | 11 ++++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 14baa01fbf..943d81366c 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -176,7 +176,7 @@ def _CheckDevtoolsStyle(input_api, output_api): affected_files = _getAffectedFiles(input_api, default_linted_directories, ['D'], ['.js', '.ts']) # If we have not changed any lintable files, then we should bail out. - # Otherwise, `run_lint_check.py` will lint *all* files. + # Otherwise, `run_lint_check.js` will lint *all* files. if len(affected_files) is 0: results.append(output_api.PresubmitNotifyResult('No affected files for ESLint check')) return results diff --git a/package.json b/package.json index 8b9e7af01a..34e6084e50 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "check-gn": "node scripts/check_gn.js", "check-grdp": "node scripts/localization/check_localizable_resources.js", "check-json": "node scripts/json_validator/validate_module_json.js", - "check-lint": "python scripts/test/run_lint_check.py", + "check-lint": "third_party/node/node.py scripts/test/run_lint_check.js", "check-loc": "python scripts/test/run_localization_check.py", "check-type": "echo \"If you want to typecheck with TypeScript, run \\\"autoninja -C out/X\\\". If you want to typecheck with Closure, run \\\"npm run check-type-closure\\\"\"", "check-type-closure": "python scripts/test/run_type_check.py", diff --git a/third_party/node/node.py b/third_party/node/node.py index ac4eac392c..1c8ec27792 100755 --- a/third_party/node/node.py +++ b/third_party/node/node.py @@ -7,6 +7,7 @@ from os import path as os_path import platform import subprocess import sys +import os def GetBinaryPath(): @@ -18,12 +19,16 @@ def GetBinaryPath(): }[platform.system()]) -def RunNode(cmd_parts, stdout=None): - cmd = " ".join([GetBinaryPath()] + cmd_parts) - process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) +def RunNode(cmd_parts): + cmd = [GetBinaryPath()] + cmd_parts + process = subprocess.Popen(cmd, cwd=os.getcwd()) stdout, stderr = process.communicate() if stderr: raise RuntimeError('%s failed: %s' % (cmd, stderr)) return stdout + + +if __name__ == '__main__': + RunNode(sys.argv[1:])