| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # This Source Code Form is subject to the terms of the Mozilla Public | 3 # This Source Code Form is subject to the terms of the Mozilla Public |
| 4 # License, v. 2.0. If a copy of the MPL was not distributed with this | 4 # License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. | 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 6 | 6 |
| 7 import sys | 7 import sys |
| 8 import os | 8 import os |
| 9 import posixpath | 9 import posixpath |
| 10 import re | 10 import re |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 256 Additionally, make sure that any VCS will ignore the installed files. | 256 Additionally, make sure that any VCS will ignore the installed files. |
| 257 | 257 |
| 258 Requires Node.js to be installed locally. | 258 Requires Node.js to be installed locally. |
| 259 """ | 259 """ |
| 260 try: | 260 try: |
| 261 with open(os.path.join(target, 'package.json'), 'r') as fp: | 261 with open(os.path.join(target, 'package.json'), 'r') as fp: |
| 262 package_data = json.load(fp) | 262 package_data = json.load(fp) |
| 263 | 263 |
| 264 # In case a package.json does not exist at all or if there are no | 264 # In case a package.json does not exist at all or if there are no |
| 265 # production dependencies declared, we don't need to run npm and can | 265 # production dependencies declared, we don't need to run npm and can |
| 266 # bail out early | 266 # bail out early. |
|
Vasily Kuznetsov
2017/08/25 18:37:40
Nit: please add periods to the comments that are c
tlucas
2017/08/28 06:53:16
Done.
| |
| 267 if not package_data.get('dependencies', False): | 267 if not package_data.get('dependencies', False): |
| 268 return | 268 return |
| 269 except IOError: | 269 except IOError: |
| 270 return | 270 return |
| 271 | 271 |
| 272 try: | 272 try: |
| 273 cmd = ['npm', 'install', '--only=production', '--loglevel=warn'] | 273 cmd = ['npm', 'install', '--only=production', '--loglevel=warn'] |
| 274 subprocess.check_output(cmd, cwd=target) | 274 subprocess.check_output(cmd, cwd=target) |
| 275 | 275 |
| 276 # Make sure Node.js related files / folders are ignored by the VCS in | 276 repo_types[vcs].ignore(os.path.join(target, 'node_modules'), target) |
|
Vasily Kuznetsov
2017/08/25 18:37:40
It seems that this comment is redundant given that
tlucas
2017/08/28 06:53:16
Done.
| |
| 277 # use | |
| 278 repo_types[vcs].ignore( | |
|
Vasily Kuznetsov
2017/08/25 18:37:40
Wouldn't this be more readable as one line?
tlucas
2017/08/28 06:53:16
Done.
| |
| 279 os.path.join(target, 'node_modules'), target | |
| 280 ) | |
| 281 except OSError as e: | 277 except OSError as e: |
| 282 import errno | 278 import errno |
| 283 if e.errno == errno.ENOENT: | 279 if e.errno == errno.ENOENT: |
| 284 logging.error('Failed to install Node.js dependencies for %s,' | 280 logging.error('Failed to install Node.js dependencies for %s,' |
| 285 ' please ensure Node.js is installed.', target) | 281 ' please ensure Node.js is installed.', target) |
| 286 else: | 282 else: |
| 287 raise | 283 raise |
| 288 | 284 |
| 289 | 285 |
| 290 def ensure_repo(parentrepo, parenttype, target, type, root, sourcename): | 286 def ensure_repo(parentrepo, parenttype, target, type, root, sourcename): |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 args = parser.parse_args() | 415 args = parser.parse_args() |
| 420 | 416 |
| 421 if args.quiet: | 417 if args.quiet: |
| 422 logging.disable(logging.INFO) | 418 logging.disable(logging.INFO) |
| 423 | 419 |
| 424 repos = args.repos | 420 repos = args.repos |
| 425 if not len(repos): | 421 if not len(repos): |
| 426 repos = [os.path.dirname(__file__)] | 422 repos = [os.path.dirname(__file__)] |
| 427 for repo in repos: | 423 for repo in repos: |
| 428 resolve_deps(repo) | 424 resolve_deps(repo) |
| LEFT | RIGHT |