Index: third_party/WebKit/Source/devtools/scripts/local_node/node.py |
diff --git a/third_party/WebKit/Source/devtools/scripts/local_node/node.py b/third_party/WebKit/Source/devtools/scripts/local_node/node.py |
index 09fd0f2dd14ccc14b02351efa0a2c4ff35b0e840..fc7be51efa39fa3ae73032effb02c45488616d06 100755 |
--- a/third_party/WebKit/Source/devtools/scripts/local_node/node.py |
+++ b/third_party/WebKit/Source/devtools/scripts/local_node/node.py |
@@ -3,6 +3,7 @@ |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+import argparse |
import os |
import shutil |
import sys |
@@ -100,6 +101,16 @@ def install_latest_node_js(version, tmp_dir): |
def main(mode=None): |
+ parser = argparse.ArgumentParser() |
+ parser.add_argument('--running-as-hook', action='store_true') |
+ args, rest_args = parser.parse_known_args() |
+ |
+ # Exit early if this is being invoked from `gclient runhooks` |
+ # and INSTALL_NODE_FOR_DEVTOOLS=1 isn't present in the environment. |
+ if (args.running_as_hook and |
+ os.environ.get('INSTALL_NODE_FOR_DEVTOOLS', '0') != '1'): |
+ return 0 |
+ |
version = os.environ.get('NODE_VERSION', DEFAULT_VERSION) |
try: |
tmp_dir = tempfile.mkdtemp(dir=THIS_DIR) |
@@ -112,7 +123,7 @@ def main(mode=None): |
# TODO(hinoka): How about Windows...? |
bin_location = os.path.join(os.path.dirname(bin_location), 'npm') |
- return subprocess.call([bin_location, ] + sys.argv[1:]) |
+ return subprocess.call([bin_location, ] + rest_args) |
if __name__ == '__main__': |