Chromium Code Reviews| 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..70735ff5c7c12c4c793461c04f8542d7f4a6a953 100755 |
| --- a/third_party/WebKit/Source/devtools/scripts/local_node/node.py |
| +++ b/third_party/WebKit/Source/devtools/scripts/local_node/node.py |
| @@ -15,7 +15,7 @@ THIS_DIR = os.path.dirname(os.path.abspath(__file__)) |
| DEFAULT_VERSION = '4.5.0' |
| BUCKET = 'chromium-nodejs' |
| - |
| +RUNNING_AS_HOOK_FLAG = '--running-as-hook' |
| def install_latest_node_js(version, tmp_dir): |
| target_dir = os.path.join(THIS_DIR, 'runtimes', version) |
| @@ -100,6 +100,12 @@ def install_latest_node_js(version, tmp_dir): |
| def main(mode=None): |
| + # Exit early if this is being invoked from `gclient runhooks` |
| + # and INSTALL_NODE_FOR_DEVTOOLS=1 isn't present in the environment. |
| + if (RUNNING_AS_HOOK_FLAG in sys.argv[1:] and |
| + os.environ.get('INSTALL_NODE_FOR_DEVTOOLS', '0') != '1'): |
| + return 0 |
| + |
|
Dirk Pranke
2016/11/11 02:11:20
I'd rewrite this section to use argparse, e.g.:
chenwilliam
2016/12/06 18:22:09
Done.
|
| version = os.environ.get('NODE_VERSION', DEFAULT_VERSION) |
| try: |
| tmp_dir = tempfile.mkdtemp(dir=THIS_DIR) |
| @@ -112,7 +118,8 @@ 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:]) |
| + node_args = [arg for arg in sys.argv[1:] if arg != RUNNING_AS_HOOK_FLAG] |
| + return subprocess.call([bin_location, ] + node_args) |
| if __name__ == '__main__': |