Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(bootstrap): Move all filter logging into get-filtered-packages me…
…thod
  • Loading branch information
evocateur committed Oct 15, 2019
1 parent a706023 commit 54dca56
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
20 changes: 0 additions & 20 deletions commands/bootstrap/index.js
Expand Up @@ -134,26 +134,6 @@ class BootstrapCommand extends Command {
let chain = Promise.resolve();

chain = chain.then(() => {
if (this.options.scope) {
this.logger.notice("filter", "including %j", this.options.scope);
}

if (this.options.ignore) {
this.logger.notice("filter", "excluding %j", this.options.ignore);
}

if (this.options.since) {
this.logger.notice("filter", "changed since %j", this.options.since);
}

if (this.options.includeFilteredDependents) {
this.logger.notice("filter", "including filtered dependents");
}

if (this.options.includeFilteredDependencies) {
this.logger.notice("filter", "including filtered dependencies");
}

return getFilteredPackages(this.targetGraph, this.execOpts, this.options);
});

Expand Down
15 changes: 15 additions & 0 deletions core/filter-options/lib/get-filtered-packages.js
@@ -1,11 +1,20 @@
"use strict";

const log = require("npmlog");
const collectUpdates = require("@lerna/collect-updates");
const filterPackages = require("@lerna/filter-packages");

module.exports = getFilteredPackages;

function getFilteredPackages(packageGraph, execOpts, options) {
if (options.scope) {
log.notice("filter", "including %j", options.scope);
}

if (options.ignore) {
log.notice("filter", "excluding %j", options.ignore);
}

let chain = Promise.resolve();

chain = chain.then(() =>
Expand All @@ -19,6 +28,8 @@ function getFilteredPackages(packageGraph, execOpts, options) {
);

if (options.since !== undefined) {
log.notice("filter", "changed since %j", options.since);

chain = chain.then(filteredPackages =>
Promise.resolve(collectUpdates(filteredPackages, packageGraph, execOpts, options)).then(updates => {
const updated = new Set(updates.map(({ pkg }) => pkg.name));
Expand All @@ -29,10 +40,14 @@ function getFilteredPackages(packageGraph, execOpts, options) {
}

if (options.includeFilteredDependents) {
log.notice("filter", "including filtered dependents");

chain = chain.then(filteredPackages => packageGraph.addDependents(filteredPackages));
}

if (options.includeFilteredDependencies) {
log.notice("filter", "including filtered dependencies");

chain = chain.then(filteredPackages => packageGraph.addDependencies(filteredPackages));
}

Expand Down
3 changes: 2 additions & 1 deletion core/filter-options/package.json
Expand Up @@ -34,6 +34,7 @@
"dependencies": {
"@lerna/collect-updates": "file:../../utils/collect-updates",
"@lerna/filter-packages": "file:../../utils/filter-packages",
"dedent": "^0.7.0"
"dedent": "^0.7.0",
"npmlog": "^4.1.2"
}
}
3 changes: 2 additions & 1 deletion package-lock.json

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

0 comments on commit 54dca56

Please sign in to comment.