/
lerna-bootstrap-hoist.test.js
81 lines (72 loc) · 2.69 KB
/
lerna-bootstrap-hoist.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"use strict";
const fs = require("fs-extra");
const globby = require("globby");
const cliRunner = require("@lerna-test/cli-runner");
const initFixture = require("@lerna-test/init-fixture")(__dirname);
test("lerna bootstrap --hoist", async () => {
const cwd = await initFixture("lerna-bootstrap");
const lerna = cliRunner(cwd);
/* eslint-disable max-len */
const { stderr } = await lerna("bootstrap", "--concurrency=1", "--no-ci", "--hoist");
expect(stderr).toMatchInlineSnapshot(`
lerna notice cli __TEST_VERSION__
lerna info Bootstrapping 4 packages
lerna info lifecycle package-4@1.0.0~preinstall: package-4@1.0.0
lerna WARN EHOIST_PKG_VERSION "@integration/package-3" package depends on pify@^1.0.0, which differs from the hoisted pify@^2.0.0.
lerna info Installing external dependencies
lerna info hoist Installing hoisted dependencies into root
lerna info hoist Finished bootstrapping root
lerna info hoist Pruning hoisted dependencies
lerna info hoist Finished pruning hoisted dependencies
lerna info Symlinking packages and binaries
lerna info lifecycle @integration/package-3@1.0.0~postinstall: @integration/package-3@1.0.0
lerna info lifecycle @integration/package-2@1.0.0~prepublish: @integration/package-2@1.0.0
lerna info lifecycle @integration/package-1@1.0.0~prepare: @integration/package-1@1.0.0
lerna success Bootstrapped 4 packages
`);
// the "--silent" flag is passed to `npm run`
const { stdout } = await lerna("run", "test", "--concurrency=1", "--", "--silent");
expect(stdout).toMatchInlineSnapshot(`
package-1
package-2
cli package-2 OK
package-3 cli1 OK
package-3 cli2 package-2 OK
`);
const config = {
cwd,
absolute: true,
followSymbolicLinks: false,
};
const lockfiles = await globby(["**/package-lock.json"], config);
const [lock3, rootLock] = await Promise.all(lockfiles.sort().map((fp) => fs.readJson(fp)));
expect(lock3).toMatchObject({
name: "@integration/package-3",
version: "1.0.0",
dependencies: { pify: expect.any(Object) },
});
expect(rootLock).toMatchObject({
name: "integration",
version: "0.0.0",
dependencies: {
pify: expect.any(Object),
"tiny-tarball": {
version: "1.0.0",
// root hoist does not preserve optional
},
},
});
expect(rootLock).not.toHaveProperty("dependencies.tiny-tarball.optional");
});
test("postinstall does not recurse", async () => {
const cwd = await initFixture("lerna-bootstrap");
const lerna = cliRunner(cwd, {
LERNA_EXEC_PATH: cwd,
LERNA_ROOT_PATH: cwd,
});
const { stderr } = await lerna("bootstrap", "--no-ci", "--hoist");
expect(stderr).toMatchInlineSnapshot(`
lerna notice cli __TEST_VERSION__
lerna WARN bootstrap Skipping recursive execution
`);
});