Skip to content

Commit

Permalink
fix: Respect durable hoist configuration
Browse files Browse the repository at this point in the history
fixes #1325
  • Loading branch information
evocateur committed Mar 19, 2018
1 parent f15b224 commit 2081640
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
16 changes: 14 additions & 2 deletions commands/bootstrap/__tests__/bootstrap-command.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const createSymlink = require("@lerna/create-symlink");
// helpers
const initFixture = require("@lerna-test/init-fixture")(__dirname);
const normalizeRelativeDir = require("@lerna-test/normalize-relative-dir");
const updateLernaConfig = require("@lerna-test/update-lerna-config");

// file under test
const lernaBootstrap = require("@lerna-test/command-runner")(require("../command"));
Expand Down Expand Up @@ -282,7 +283,10 @@ describe("BootstrapCommand", () => {
it("hoists appropriately", async () => {
const testDir = await initFixture("cold");

await lernaBootstrap(testDir)("--hoist");
await updateLernaConfig(testDir, {
hoist: true,
});
await lernaBootstrap(testDir)();

expect(installedPackagesInDirectories(testDir)).toMatchSnapshot();
expect(symlinkedDirectories(testDir)).toMatchSnapshot();
Expand All @@ -301,7 +305,15 @@ describe("BootstrapCommand", () => {
it("hoists appropriately", async () => {
const testDir = await initFixture("warm");

await lernaBootstrap(testDir)("--hoist");
await updateLernaConfig(testDir, {
command: {
// "commands" also supported
bootstrap: {
hoist: true,
},
},
});
await lernaBootstrap(testDir)();

expect(installedPackagesInDirectories(testDir)).toMatchSnapshot();
expect(symlinkedDirectories(testDir)).toMatchSnapshot();
Expand Down
14 changes: 13 additions & 1 deletion commands/bootstrap/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,19 @@ class BootstrapCommand extends Command {
let hoisting;

if (hoist) {
hoisting = [].concat(hoist, nohoist || []);
if (hoist === true) {
// lerna.json `hoist: true`
hoisting = ["**"];
} else {
// `--hoist ...` or lerna.json `hoist: [...]`
hoisting = [].concat(hoist);
}

if (nohoist) {
// `--nohoist ...` or lerna.json `nohoist: [...]`
hoisting = hoisting.concat(nohoist);
}

tracker.verbose("hoist", "using globs %j", hoisting);
}

Expand Down

0 comments on commit 2081640

Please sign in to comment.