Cleanup _checkWithNodeScript

It can use the same _ExecuteSubProcess helper and remove some
duplication on how to handle the script_arguments.

Change-Id: Iec7a32c7a0c173e92e0fd195f4cbc40b70665b03
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2087769
Commit-Queue: Tim van der Lippe <[email protected]>
Reviewed-by: Jack Franklin <[email protected]>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 4aa6024..d8d6982 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -307,7 +307,7 @@
     return affected_files
 
 
-def _checkWithNodeScript(input_api, output_api, script_path, script_arguments=None):  # pylint: disable=invalid-name
+def _checkWithNodeScript(input_api, output_api, script_path, script_arguments=[]):  # pylint: disable=invalid-name
     original_sys_path = sys.path
     try:
         sys.path = sys.path + [input_api.os_path.join(input_api.PresubmitLocalPath(), 'scripts')]
@@ -315,15 +315,4 @@
     finally:
         sys.path = original_sys_path
 
-    node_path = devtools_paths.node_path()
-
-    if script_arguments is None:
-        script_arguments = []
-
-    process = input_api.subprocess.Popen(
-        [node_path, script_path] + script_arguments, stdout=input_api.subprocess.PIPE, stderr=input_api.subprocess.STDOUT)
-    out, _ = process.communicate()
-
-    if process.returncode != 0:
-        return [output_api.PresubmitError(out)]
-    return [output_api.PresubmitNotifyResult(out)]
+    return _ExecuteSubProcess(input_api, output_api, [devtools_paths.node_path(), script_path], script_arguments, [])