forked from Laboratoria/BOG004-md-links
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
30 lines (29 loc) · 763 Bytes
/
cli.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
#!/usr/bin/env node
const { getStats, broken } = require("./index.js");
const mdLinks = require("./md-Links.js");
const args = process.argv;
const options = {
validate: false,
stats: false,
};
const cli = () => {
if (args.includes("--validate")) {
options.validate = true;
}
if (args.includes("--stats")) {
options.stats = true;
}
mdLinks(args[2], options)
.then((respuesta) => {
if (options.validate && options.stats) {
console.table(broken(respuesta));
console.table(getStats(respuesta));
} else if (options.stats) {
console.table(getStats(respuesta));
} else if (options.validate) {
console.log("RESPUESTA", respuesta);
}
})
.catch((err) => console.log(err));
};
cli();