forked from Laboratoria/SAP004-md-links
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·23 lines (18 loc) · 865 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
#!/usr/bin/env node
const { getLinks, getLinksWithValidation } = require('./main');
const { renderLog, simpleLogger, statsLogger, renderLogWithStats, statsWithValidateLogger, validateLogger } = require('./loggers');
function cli() {
console.log('Processing file 🧶🐱');
const path = process.argv[2];
switch (true) {
case process.argv.includes('--validate') && process.argv.includes('--stats'):
return getLinksWithValidation(path).then((links) => renderLogWithStats(links, statsWithValidateLogger));
case process.argv.includes('--validate'):
return getLinksWithValidation(path).then((links) => renderLog(links, validateLogger));
case process.argv.includes('--stats'):
return renderLogWithStats(getLinks(path), statsLogger);
default:
return renderLog(getLinks(path), simpleLogger);
}
}
module.exports = cli();