-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcli.js
More file actions
54 lines (50 loc) · 1.12 KB
/
Copy pathcli.js
File metadata and controls
54 lines (50 loc) · 1.12 KB
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
#!/usr/bin/env node
"use strict";
const meow = require("meow");
const chalk = require("chalk");
const getInput = require("./src/index");
const path = require("path");
const fs = require("fs");
const loadJsonFile = require("load-json-file");
const { displayRec } = require("./src/display");
const cli = meow(
`
Usage
$ farch
Examples
$ farch
Options
-R Allow to perform assertion recursively
`,
{
flags: {
R: {
type: "boolean"
}
}
}
);
const main = () => {
try {
Promise.resolve()
.then(() => {
const data = fs.existsSync(path.resolve("farch.json"))
? loadJsonFile.sync(path.resolve("farch.json"))
: loadJsonFile.sync(path.resolve("package.json"));
return data;
})
.then(data => {
return Promise.all(getInput(data, cli.flags)).then(report => report);
})
.then(dataToDisplay => {
console.log(chalk`\n {bold ${"Report linter-farch:\n"}}`);
displayRec(dataToDisplay);
});
} catch (e) {
if (e) {
console.log(chalk` {red.bold ${e.message}}`);
return;
}
}
};
main();