Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Unified Diff: third_party/WebKit/Source/devtools/scripts/local_node/node.py

Issue 2486903002: DevTools: Add support for installing node and running eslint over devtools. (Closed)
Patch Set: fix node.py Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/devtools/scripts/buildbot/run_eslint.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c881c875c514962cd430851e8f21a070cbdfa02d 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
@@ -87,7 +88,7 @@ def install_latest_node_js(version, tmp_dir):
# Still potentiall racy, from python docs:
# "On Windows...there may be no way to implement an atomic rename when dst
# names an existing file."
- os.mkdir(target_dir)
+ os.makedirs(target_dir)
os.rename(dest, bin_location)
except OSError:
write_version = False
@@ -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 not on a bot (CHROME_HEADLESS is set on all build bots).
+ if (args.running_as_hook and
+ os.environ.get('CHROME_HEADLESS', '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__':
« no previous file with comments | « third_party/WebKit/Source/devtools/scripts/buildbot/run_eslint.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698