From d32feaac744dafc717264861616cedc3a91d4cc4 Mon Sep 17 00:00:00 2001 From: Daniel Stockman Date: Tue, 18 Dec 2018 15:13:06 -0800 Subject: [PATCH] fix(bootstrap): Use run-lifecycle factory instead of manual filtering --- commands/bootstrap/index.js | 26 ++++++++------------------ commands/bootstrap/package.json | 1 - package-lock.json | 1 - 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/commands/bootstrap/index.js b/commands/bootstrap/index.js index b45d5ee6b6..8c18e24b80 100644 --- a/commands/bootstrap/index.js +++ b/commands/bootstrap/index.js @@ -12,9 +12,8 @@ const pWaterfall = require("p-waterfall"); const Command = require("@lerna/command"); const rimrafDir = require("@lerna/rimraf-dir"); const hasNpmVersion = require("@lerna/has-npm-version"); -const npmConf = require("@lerna/npm-conf"); const npmInstall = require("@lerna/npm-install"); -const runLifecycle = require("@lerna/run-lifecycle"); +const { createRunner } = require("@lerna/run-lifecycle"); const batchPackages = require("@lerna/batch-packages"); const runParallelBatches = require("@lerna/run-parallel-batches"); const symlinkBinary = require("@lerna/symlink-binary"); @@ -63,7 +62,7 @@ class BootstrapCommand extends Command { ); } - this.conf = npmConf({ registry }); + this.runPackageLifecycle = createRunner({ registry }); this.npmConfig = { registry, npmClient, @@ -176,24 +175,15 @@ class BootstrapCommand extends Command { return; } - const packagesWithScript = new Set(this.filteredPackages.filter(pkg => pkg.scripts[stage])); - - if (!packagesWithScript.size) { - return; - } - const tracker = this.logger.newItem(stage); - const mapPackageWithScript = pkg => { - if (packagesWithScript.has(pkg)) { - return runLifecycle(pkg, stage, this.conf).then(() => { - tracker.silly("lifecycle", "finished", pkg.name); - tracker.completeWork(1); - }); - } - }; + const mapPackageWithScript = pkg => + this.runPackageLifecycle(pkg, stage).then(() => { + tracker.silly("lifecycle", "finished %j in %s", stage, pkg.name); + tracker.completeWork(1); + }); - tracker.addWork(packagesWithScript.size); + tracker.addWork(this.filteredPackages.length); return pFinally(runParallelBatches(this.batchedPackages, this.concurrency, mapPackageWithScript), () => tracker.finish() diff --git a/commands/bootstrap/package.json b/commands/bootstrap/package.json index 4591fbf820..1ce457c98e 100644 --- a/commands/bootstrap/package.json +++ b/commands/bootstrap/package.json @@ -39,7 +39,6 @@ "@lerna/command": "file:../../core/command", "@lerna/filter-options": "file:../../core/filter-options", "@lerna/has-npm-version": "file:../../utils/has-npm-version", - "@lerna/npm-conf": "file:../../utils/npm-conf", "@lerna/npm-install": "file:../../utils/npm-install", "@lerna/package-graph": "file:../../core/package-graph", "@lerna/rimraf-dir": "file:../../utils/rimraf-dir", diff --git a/package-lock.json b/package-lock.json index 4d38a9cc21..c71b9b66dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -291,7 +291,6 @@ "@lerna/command": "file:core/command", "@lerna/filter-options": "file:core/filter-options", "@lerna/has-npm-version": "file:utils/has-npm-version", - "@lerna/npm-conf": "file:utils/npm-conf", "@lerna/npm-install": "file:utils/npm-install", "@lerna/package-graph": "file:core/package-graph", "@lerna/rimraf-dir": "file:utils/rimraf-dir",