Improve progress bar when using delta dependencies traversal

Reviewed By: davidaurelio

Differential Revision: D5901052

fbshipit-source-id: a06584bfbd287f6d8d9b53fb5918dfa7d88bceef
This commit is contained in:
Rafael Oleza 2017-09-28 15:06:50 -07:00 committed by Facebook Github Bot
parent a606e79af0
commit 07d73a3af2
1 changed files with 16 additions and 4 deletions

View File

@ -132,15 +132,19 @@ async function traverseDependenciesForSingleFile(
dependencyGraph,
transformOptions,
edges,
() => {
total++;
onProgress(numProcessed, total);
},
() => {
numProcessed++;
onProgress(numProcessed, total);
},
);
} else {
newDependencies = new Set();
}
numProcessed += newDependencies.size + 1;
total += newDependencies.size;
onProgress(numProcessed, total);
return newDependencies;
}),
);
@ -177,6 +181,8 @@ async function addDependency(
dependencyGraph: DependencyGraph,
transformOptions: JSTransformerOptions,
edges: DependencyEdges,
onDependencyAdd: () => mixed,
onDependencyAdded: () => mixed,
): Promise<Set<string>> {
const parentModule = dependencyGraph.getModuleForPath(parentEdge.path);
const module = dependencyGraph.resolveDependency(
@ -197,6 +203,8 @@ async function addDependency(
return new Set();
}
onDependencyAdd();
// Create the new edge and traverse all its subdependencies, looking for new
// subdependencies recursively.
dependencyEdge = createEdge(module.path, edges);
@ -219,6 +227,8 @@ async function addDependency(
dependencyGraph,
transformOptions,
edges,
onDependencyAdd,
onDependencyAdded,
),
),
);
@ -227,6 +237,8 @@ async function addDependency(
addedDependencies.add(newDependency);
}
onDependencyAdded();
return addedDependencies;
}