Skip to content

Commit 2081640

Browse files
committed
fix: Respect durable hoist configuration
fixes #1325
1 parent f15b224 commit 2081640

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

commands/bootstrap/__tests__/bootstrap-command.test.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const createSymlink = require("@lerna/create-symlink");
1717
// helpers
1818
const initFixture = require("@lerna-test/init-fixture")(__dirname);
1919
const normalizeRelativeDir = require("@lerna-test/normalize-relative-dir");
20+
const updateLernaConfig = require("@lerna-test/update-lerna-config");
2021

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

285-
await lernaBootstrap(testDir)("--hoist");
286+
await updateLernaConfig(testDir, {
287+
hoist: true,
288+
});
289+
await lernaBootstrap(testDir)();
286290

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

304-
await lernaBootstrap(testDir)("--hoist");
308+
await updateLernaConfig(testDir, {
309+
command: {
310+
// "commands" also supported
311+
bootstrap: {
312+
hoist: true,
313+
},
314+
},
315+
});
316+
await lernaBootstrap(testDir)();
305317

306318
expect(installedPackagesInDirectories(testDir)).toMatchSnapshot();
307319
expect(symlinkedDirectories(testDir)).toMatchSnapshot();

commands/bootstrap/index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,19 @@ class BootstrapCommand extends Command {
212212
let hoisting;
213213

214214
if (hoist) {
215-
hoisting = [].concat(hoist, nohoist || []);
215+
if (hoist === true) {
216+
// lerna.json `hoist: true`
217+
hoisting = ["**"];
218+
} else {
219+
// `--hoist ...` or lerna.json `hoist: [...]`
220+
hoisting = [].concat(hoist);
221+
}
222+
223+
if (nohoist) {
224+
// `--nohoist ...` or lerna.json `nohoist: [...]`
225+
hoisting = hoisting.concat(nohoist);
226+
}
227+
216228
tracker.verbose("hoist", "using globs %j", hoisting);
217229
}
218230

0 commit comments

Comments
 (0)