Skip to content

Commit

Permalink
fix(bootstrap): Run lifecycle scripts in topological queue instead of…
Browse files Browse the repository at this point in the history
… batches (#2224)
  • Loading branch information
nicolo-ribaudo authored and evocateur committed Oct 7, 2019
1 parent afb0414 commit d8d33f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
18 changes: 9 additions & 9 deletions commands/bootstrap/index.js
Expand Up @@ -14,8 +14,7 @@ const rimrafDir = require("@lerna/rimraf-dir");
const hasNpmVersion = require("@lerna/has-npm-version");
const npmInstall = require("@lerna/npm-install");
const { createRunner } = require("@lerna/run-lifecycle");
const batchPackages = require("@lerna/batch-packages");
const runParallelBatches = require("@lerna/run-parallel-batches");
const runTopologically = require("@lerna/run-topologically");
const symlinkBinary = require("@lerna/symlink-binary");
const symlinkDependencies = require("@lerna/symlink-dependencies");
const ValidationError = require("@lerna/validation-error");
Expand Down Expand Up @@ -178,10 +177,6 @@ class BootstrapCommand extends Command {
});

chain = chain.then(() => {
this.batchedPackages = this.toposort
? batchPackages(this.filteredPackages, this.options.rejectCycles)
: [this.filteredPackages];

if (npmClient === "yarn" && !mutex) {
return getPort({ port: 42424, host: "0.0.0.0" }).then(port => {
this.npmConfig.mutex = `network:${port}`;
Expand Down Expand Up @@ -281,9 +276,14 @@ class BootstrapCommand extends Command {

tracker.addWork(this.filteredPackages.length);

return pFinally(runParallelBatches(this.batchedPackages, this.concurrency, mapPackageWithScript), () =>
tracker.finish()
);
const runner = this.toposort
? runTopologically(this.filteredPackages, mapPackageWithScript, {
concurrency: this.concurrency,
rejectCycles: this.options.rejectCycles,
})
: pMap(this.filteredPackages, mapPackageWithScript, { concurrency: this.concurrency });

return pFinally(runner, () => tracker.finish());
}

hoistedDirectory(dependency) {
Expand Down
3 changes: 1 addition & 2 deletions commands/bootstrap/package.json
Expand Up @@ -36,7 +36,6 @@
"populate--": true
},
"dependencies": {
"@lerna/batch-packages": "file:../../utils/batch-packages",
"@lerna/command": "file:../../core/command",
"@lerna/filter-options": "file:../../core/filter-options",
"@lerna/has-npm-version": "file:../../utils/has-npm-version",
Expand All @@ -45,7 +44,7 @@
"@lerna/pulse-till-done": "file:../../utils/pulse-till-done",
"@lerna/rimraf-dir": "file:../../utils/rimraf-dir",
"@lerna/run-lifecycle": "file:../../utils/run-lifecycle",
"@lerna/run-parallel-batches": "file:../../utils/run-parallel-batches",
"@lerna/run-topologically": "file:../../utils/run-topologically",
"@lerna/symlink-binary": "file:../../utils/symlink-binary",
"@lerna/symlink-dependencies": "file:../../utils/symlink-dependencies",
"@lerna/validation-error": "file:../../core/validation-error",
Expand Down
17 changes: 1 addition & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d8d33f7

Please sign in to comment.