return this._resolver.getAllModules().then(allModules => { const changed = new Set(); for (const path of changedPaths) { if (this._resolver.getFS().fileExists(path)) { const module = this._resolver.getModuleForPath(path); if (module) { changed.add(module.path); if (this._isTestFilePath(module.path)) { relatedPaths.add(module.path); } } } } return Promise.all(Object.keys(allModules).map(path => this._resolver.getShallowDependencies(path) .then(response => ({ name: path, path, dependencies: response.dependencies.map(dep => dep.path), })) )).then(moduleMap => Array.from(this.collectChangedModules( relatedPaths, moduleMap, changed ))); });
const nextResolution = () => { if (i >= moduleMap.length) { return; } const currentIndex = i; const module = moduleMap[currentIndex]; const deferred = deferreds[currentIndex]; i++; this._resolver.getModuleForPath(module.path).getDependencies() .then(dependencies => { nextResolution(); moduleMap[currentIndex].dependencies = dependencies; }) .then(() => deferred.resolve()); };