forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.test.js
More file actions
31 lines (25 loc) · 754 Bytes
/
cli.test.js
File metadata and controls
31 lines (25 loc) · 754 Bytes
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
import { test, expect } from "vitest";
import { createRequire } from "node:module";
import { git } from "@commitlint/test";
import { x } from "tinyexec";
const require = createRequire(import.meta.url);
const bin = require.resolve("./cli.js");
const cli = (args, options) => {
return (input = "") => {
const result = x(bin, args, {
nodeOptions: {
cwd: options.cwd,
env: options.env,
},
});
result.process.stdin.write(input);
result.process.stdin.end();
return result;
};
};
test("should print warning if stage is empty", async () => {
const cwd = await git.bootstrap();
const actual = await cli([], { cwd })("foo: bar");
expect(actual.stdout).toContain("Nothing to commit.");
expect(actual.stderr).toBe("");
}, 10000);