Skip to content

Commit

Permalink
fix(add): Compose bootstrap to avoid extra logs
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Aug 17, 2018
1 parent 7f97c7b commit 3c534eb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions commands/add/__tests__/add-command.test.js
Expand Up @@ -194,7 +194,10 @@ describe("AddCommand", () => {

expect(bootstrap).lastCalledWith(
expect.objectContaining({
args: [],
cwd: testDir,
scope: ["@test/package-2", "package-3", "package-4"],
composed: "add",
})
);
});
Expand Down
20 changes: 10 additions & 10 deletions commands/add/index.js
Expand Up @@ -72,18 +72,18 @@ class AddCommand extends Command {
this.packagesToChange.length > 1 ? "s" : ""
}`;

this.logger.info("add", `adding ${this.spec.name} in ${numberOfPackages}`);
this.logger.info("", `Adding ${this.spec.name} in ${numberOfPackages}`);

return this.makeChanges().then(() => {
this.logger.info("add", `Bootstrapping ${numberOfPackages}`);

return bootstrap(
Object.assign({}, this.options, {
args: [],
cwd: this.project.rootPath,
scope: this.packagesToChange.map(pkg => pkg.name),
})
);
const argv = Object.assign({}, this.options, {
args: [],
cwd: this.project.rootPath,
scope: this.packagesToChange.map(pkg => pkg.name),
// silence initial cli version logging, etc
composed: "add",
});

return bootstrap(argv);
});
}

Expand Down
10 changes: 9 additions & 1 deletion integration/lerna-add.test.js
Expand Up @@ -15,7 +15,15 @@ describe("lerna add", () => {
test("add to all packages", async () => {
const cwd = await initFixture("lerna-add");

await cliRunner(cwd)("add", "@test/package-1");
const { stderr } = await cliRunner(cwd)("add", "@test/package-1");
expect(stderr).toMatchInlineSnapshot(`
lerna notice cli __TEST_VERSION__
lerna info Adding @test/package-1 in 3 packages
lerna info filter [ '@test/package-2', 'package-3', 'package-4' ]
lerna info Bootstrapping 3 packages
lerna info Symlinking packages and binaries
lerna success Bootstrapped 3 packages
`);

const filePaths = await globby("packages/*/package.json", { cwd });
const [pkg1, pkg2, pkg3, pkg4] = await pMap(filePaths.sort(), fp => loadJson(path.join(cwd, fp)));
Expand Down

0 comments on commit 3c534eb

Please sign in to comment.