Index: ensure_dependencies.py |
=================================================================== |
--- a/ensure_dependencies.py |
+++ b/ensure_dependencies.py |
@@ -44,6 +44,8 @@ |
'SKIP_DEPENDENCY_UPDATES', '' |
).lower() not in ('', '0', 'false') |
+NPM_LOCKFILE = '.npm_install_lock' |
saroyanm
2017/11/28 14:49:15
Those are the changes which were updated after dep
|
+ |
class Mercurial(): |
def istype(self, repodir): |
@@ -271,10 +273,28 @@ |
return |
try: |
- cmd = ['npm', 'install', '--only=production', '--loglevel=warn'] |
+ # Create an empty file, which gets deleted after successfully |
+ # installing Node.js dependencies. |
+ lockfile_path = os.path.join(target, NPM_LOCKFILE) |
+ open(lockfile_path, 'a').close() |
+ |
+ if os.name == 'nt': |
+ # Windows' CreateProcess() (called by subprocess.Popen()) only |
+ # resolves executables ending in .exe. The windows installation of |
+ # Node.js only provides a npm.cmd, which is executable but won't |
+ # be recognized as such by CreateProcess(). |
+ npm_exec = 'npm.cmd' |
+ else: |
+ npm_exec = 'npm' |
+ |
+ cmd = [npm_exec, 'install', '--only=production', '--loglevel=warn', |
+ '--no-package-lock', '--no-optional'] |
subprocess.check_output(cmd, cwd=target) |
+ repo_types[vcs].ignore(os.path.join(target, NPM_LOCKFILE), target) |
repo_types[vcs].ignore(os.path.join(target, 'node_modules'), target) |
+ |
+ os.remove(lockfile_path) |
except OSError as e: |
import errno |
if e.errno == errno.ENOENT: |
@@ -365,7 +385,8 @@ |
repo_cloned = ensure_repo(repodir, parenttype, target, vcs, |
_root.get(vcs, ''), source) |
repo_updated = update_repo(target, vcs, rev) |
- if repo_cloned or repo_updated: |
+ recent_npm_failed = os.path.exists(os.path.join(target, NPM_LOCKFILE)) |
+ if repo_cloned or repo_updated or recent_npm_failed: |
resolve_npm_dependencies(target, vcs) |
resolve_deps(target, level + 1, self_update=False, |
overrideroots=overrideroots, skipdependencies=skipdependencies) |