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

Side by Side 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 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 unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse
6 import os 7 import os
7 import shutil 8 import shutil
8 import sys 9 import sys
9 import subprocess 10 import subprocess
10 import tarfile 11 import tarfile
11 import tempfile 12 import tempfile
12 import urllib2 13 import urllib2
13 14
14 THIS_DIR = os.path.dirname(os.path.abspath(__file__)) 15 THIS_DIR = os.path.dirname(os.path.abspath(__file__))
15 16
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 write_version = False 94 write_version = False
94 95
95 if write_version: 96 if write_version:
96 with open(version_file, 'w') as f: 97 with open(version_file, 'w') as f:
97 f.write(version) 98 f.write(version)
98 99
99 return bin_location 100 return bin_location
100 101
101 102
102 def main(mode=None): 103 def main(mode=None):
104 parser = argparse.ArgumentParser()
105 parser.add_argument('--running-as-hook', action='store_true')
106 args, rest_args = parser.parse_known_args()
107
108 # Exit early if this is being invoked from `gclient runhooks`
109 # and INSTALL_NODE_FOR_DEVTOOLS=1 isn't present in the environment.
110 if (args.running_as_hook and
111 os.environ.get('INSTALL_NODE_FOR_DEVTOOLS', '0') != '1'):
112 return 0
113
103 version = os.environ.get('NODE_VERSION', DEFAULT_VERSION) 114 version = os.environ.get('NODE_VERSION', DEFAULT_VERSION)
104 try: 115 try:
105 tmp_dir = tempfile.mkdtemp(dir=THIS_DIR) 116 tmp_dir = tempfile.mkdtemp(dir=THIS_DIR)
106 bin_location = install_latest_node_js(version, tmp_dir) 117 bin_location = install_latest_node_js(version, tmp_dir)
107 finally: 118 finally:
108 if os.path.exists(tmp_dir): 119 if os.path.exists(tmp_dir):
109 shutil.rmtree(tmp_dir) 120 shutil.rmtree(tmp_dir)
110 121
111 if mode == 'npm': 122 if mode == 'npm':
112 # TODO(hinoka): How about Windows...? 123 # TODO(hinoka): How about Windows...?
113 bin_location = os.path.join(os.path.dirname(bin_location), 'npm') 124 bin_location = os.path.join(os.path.dirname(bin_location), 'npm')
114 125
115 return subprocess.call([bin_location, ] + sys.argv[1:]) 126 return subprocess.call([bin_location, ] + rest_args)
116 127
117 128
118 if __name__ == '__main__': 129 if __name__ == '__main__':
119 sys.exit(main()) 130 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698