Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: ensure_dependencies.py

Issue 29587652: Issue 5913 - call correct npm executable on Win (Closed)
Patch Set: Created Oct. 24, 2017, 1:39 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 return 271 return
272 except IOError: 272 except IOError:
273 return 273 return
274 274
275 try: 275 try:
276 # Create an empty file, which gets deleted after successfully 276 # Create an empty file, which gets deleted after successfully
277 # installing Node.js dependencies. 277 # installing Node.js dependencies.
278 lockfile_path = os.path.join(target, NPM_LOCKFILE) 278 lockfile_path = os.path.join(target, NPM_LOCKFILE)
279 open(lockfile_path, 'a').close() 279 open(lockfile_path, 'a').close()
280 280
281 cmd = ['npm', 'install', '--only=production', '--loglevel=warn', 281 if os.name == 'nt':
282 # Windows' CreateProcess() (called by subprocess.Popen()) only
283 # resolves executables ending in .exe. The windows installation of
284 # Node.js only provides a npm.cmd, which is executable but won't
285 # be recognized as such by CreateProcess().
286 npm_exec = 'npm.cmd'
287 else:
288 npm_exec = 'npm'
289
290 cmd = [npm_exec, 'install', '--only=production', '--loglevel=warn',
282 '--no-package-lock', '--no-optional'] 291 '--no-package-lock', '--no-optional']
283 subprocess.check_output(cmd, cwd=target) 292 subprocess.check_output(cmd, cwd=target)
284 293
285 repo_types[vcs].ignore(os.path.join(target, NPM_LOCKFILE), target) 294 repo_types[vcs].ignore(os.path.join(target, NPM_LOCKFILE), target)
286 repo_types[vcs].ignore(os.path.join(target, 'node_modules'), target) 295 repo_types[vcs].ignore(os.path.join(target, 'node_modules'), target)
287 296
288 os.remove(lockfile_path) 297 os.remove(lockfile_path)
289 except OSError as e: 298 except OSError as e:
290 import errno 299 import errno
291 if e.errno == errno.ENOENT: 300 if e.errno == errno.ENOENT:
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 args = parser.parse_args() 438 args = parser.parse_args()
430 439
431 if args.quiet: 440 if args.quiet:
432 logging.disable(logging.INFO) 441 logging.disable(logging.INFO)
433 442
434 repos = args.repos 443 repos = args.repos
435 if not len(repos): 444 if not len(repos):
436 repos = [os.path.dirname(__file__)] 445 repos = [os.path.dirname(__file__)]
437 for repo in repos: 446 for repo in repos:
438 resolve_deps(repo) 447 resolve_deps(repo)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld