-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
version-ignore-changes.test.js
75 lines (58 loc) · 2.23 KB
/
version-ignore-changes.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
"use strict";
// we're actually testing integration with git
jest.unmock("@lerna/collect-updates");
// local modules _must_ be explicitly mocked
jest.mock("../lib/git-push");
jest.mock("../lib/is-anything-committed");
jest.mock("../lib/is-behind-upstream");
jest.mock("../lib/remote-branch-exists");
const fs = require("fs-extra");
const path = require("path");
// helpers
const initFixture = require("@lerna-test/init-fixture")(path.resolve(__dirname, "../../publish/__tests__"));
const gitAdd = require("@lerna-test/git-add");
const gitTag = require("@lerna-test/git-tag");
const gitCommit = require("@lerna-test/git-commit");
const showCommit = require("@lerna-test/show-commit");
// test command
const lernaVersion = require("@lerna-test/command-runner")(require("../command"));
// stabilize commit SHA
expect.addSnapshotSerializer(require("@lerna-test/serialize-git-sha"));
describe("version --ignore-changes", () => {
const setupChanges = async (cwd, tuples) => {
await gitTag(cwd, "v1.0.0");
await Promise.all(
tuples.map(([filePath, content]) => fs.outputFile(path.join(cwd, filePath), content, "utf8"))
);
await gitAdd(cwd, ".");
await gitCommit(cwd, "setup");
};
it("does not version packages with ignored changes", async () => {
const cwd = await initFixture("normal");
await setupChanges(cwd, [
["packages/package-2/README.md", "oh"],
["packages/package-3/__tests__/pkg3.test.js", "hai"],
["packages/package-4/lib/foo.js", "there"],
]);
await lernaVersion(cwd)(
"--ignore-changes",
"README.md",
"--ignore-changes",
"**/__tests__/**",
"--ignore-changes",
"package-4" // notably does NOT work, needs to be "**/package-4/**" to match
);
const changedFiles = await showCommit(cwd, "--name-only");
expect(changedFiles).toMatchSnapshot();
});
it("is mapped from deprecated --ignore", async () => {
const cwd = await initFixture("normal");
await setupChanges(cwd, [
["packages/package-3/README.md", "wat"],
["packages/package-4/lib/foo.js", "hey"],
]);
await lernaVersion(cwd)("--ignore", "*.md");
const changedFiles = await showCommit(cwd, "--name-only");
expect(changedFiles).toMatchSnapshot();
});
});