-
-
Notifications
You must be signed in to change notification settings - Fork 237
/
megalinter-cli.test.js
110 lines (102 loc) · 2.9 KB
/
megalinter-cli.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* jscpd:ignore-start */
import assert from 'assert';
import { exec as childProcessExec } from "child_process";
import * as util from "util";
const exec = util.promisify(childProcessExec);
const release = process.env.MEGALINTER_RELEASE || "beta";
const nodockerpull =
process.env.MEGALINTER_NO_DOCKER_PULL === "true" ? true : false;
const MEGA_LINTER = "mega-linter-runner ";
describe("CLI", function () {
it("(CLI) Show help", async () => {
const params = ["--help"];
const { stdout, stderr } = await exec(MEGA_LINTER + params.join(" "));
if (stderr) {
console.error(stderr);
}
assert(stdout, "stdout is set");
assert(
stdout.includes("mega-linter [options]"),
"stdout contains help content"
);
});
it("(CLI) Show version", async () => {
const params = ["--version"];
const { stdout, stderr } = await exec(MEGA_LINTER + params.join(" "));
if (stderr) {
console.error(stderr);
}
assert(stdout, "stdout is set");
assert(
stdout.includes("mega-linter-runner version"),
'stdout should contains "mega-linter-runner version"'
);
});
it("(CLI) Upgrade config", (done) => {
if (process.env.CI) {
// Skip in CI (bug to fix in CI but works locally :/ )
done();
return;
}
const params = ["--upgrade"];
exec(MEGA_LINTER + params.join(" "))
.then((res) => {
const stdout = res.stdout;
const stderr = res.stderr;
if (stderr) {
console.error(stderr);
}
assert(stdout, "stdout is set");
assert(
stdout.includes("mega-linter-runner applied"),
'stdout should contains "mega-linter-runner applied"'
);
done();
})
.catch((err) => {
done(err);
throw err;
});
}).timeout(10000);
/*
Disabled until find a way to run with default options
it('(CLI) Run installer', async () => {
const params = ["--install"];
const { stdout, stderr } = await exec(MEGA_LINTER + params.join(" "));
if (stderr) {
console.error(stderr);
}
assert(stdout, "stdout is set");
})
*/
const params = [
"--path",
"./..",
"--release",
release,
"-e",
'"ENABLE=YAML"',
];
it("(CLI) run on own code base", async () => {
if (nodockerpull) {
params.push("--nodockerpull");
}
const { stdout, stderr } = await exec(MEGA_LINTER + params.join(" "));
if (stderr) {
console.error(stderr);
}
assert(stdout, "stdout is set");
}).timeout(600000);
it("(CLI) run on own code base with json output", async () => {
params.push("--json");
if (nodockerpull) {
params.push("--nodockerpull");
}
const { stdout, stderr } = await exec(MEGA_LINTER + params.join(" "));
if (stderr) {
console.error(stderr);
}
assert(stdout, "stdout is set");
}).timeout(600000);
});
/* jscpd:ignore-end */