forked from lerna/lerna
/
npm-client-args.spec.ts
97 lines (81 loc) · 3.05 KB
/
npm-client-args.spec.ts
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { Fixture, normalizeCommitSHAs, normalizeEnvironment } from "@lerna/e2e-utils";
expect.addSnapshotSerializer({
serialize(str: string) {
return normalizeCommitSHAs(normalizeEnvironment(str));
},
test(val: string) {
return val != null && typeof val === "string";
},
});
describe("lerna-version-npm-client-args", () => {
let fixture: Fixture;
beforeEach(async () => {
fixture = await Fixture.create({
name: "lerna-version-npm-client-args",
packageManager: "npm",
initializeGit: true,
runLernaInit: true,
installDependencies: true,
});
await fixture.lerna("create package-a -y");
// eslint-plugin-react-app@6.2.2 requires a peer dependency of eslint@"6.x".
// Without it, the npm install at the end of `lerna version` will fail if
// --legacy-peer-deps is not passed correctly.
await fixture.updateJson("package.json", (json) => ({
...json,
dependencies: {
...(json.dependencies as Record<string, string>),
"eslint-plugin-react-app": "6.2.2",
eslint: "8.25.0",
},
}));
await fixture.exec(
"npm install eslint-plugin-react-app@6.2.2 eslint@8.25.0 --save=false --legacy-peer-deps"
);
await fixture.createInitialGitCommit();
await fixture.exec("git push origin test-main");
});
afterEach(() => fixture.destroy());
it("should add npmClientArgs to npm install at the end of the version command", async () => {
const output = await fixture.lerna("version 3.3.3 -y --npm-client-args=--legacy-peer-deps");
expect(output.combinedOutput).toMatchInlineSnapshot(`
lerna notice cli v999.9.9-e2e.0
lerna info current version 0.0.0
lerna info Assuming all packages changed
Changes:
- package-a: 0.0.0 => 3.3.3
lerna info auto-confirmed
lerna info execute Skipping releases
lerna info git Pushing tags...
lerna success version finished
`);
});
it("should support multiple arguments, comma delimited", async () => {
const output = await fixture.lerna('version 3.3.3 -y --npm-client-args="--legacy-peer-deps,--fund"');
expect(output.combinedOutput).toMatchInlineSnapshot(`
lerna notice cli v999.9.9-e2e.0
lerna info current version 0.0.0
lerna info Assuming all packages changed
Changes:
- package-a: 0.0.0 => 3.3.3
lerna info auto-confirmed
lerna info execute Skipping releases
lerna info git Pushing tags...
lerna success version finished
`);
});
it("should support multiple arguments, space delimited", async () => {
const output = await fixture.lerna('version 3.3.3 -y --npm-client-args="--legacy-peer-deps --fund"');
expect(output.combinedOutput).toMatchInlineSnapshot(`
lerna notice cli v999.9.9-e2e.0
lerna info current version 0.0.0
lerna info Assuming all packages changed
Changes:
- package-a: 0.0.0 => 3.3.3
lerna info auto-confirmed
lerna info execute Skipping releases
lerna info git Pushing tags...
lerna success version finished
`);
});
});