forked from Laboratoria/bog001-md-links
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·34 lines (28 loc) · 1.05 KB
/
cli.js
File metadata and controls
executable file
·34 lines (28 loc) · 1.05 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
#! / usr / bin / env nodo
//chmod + x cli.js
const mdLinks = require('./index');
const metrics = require('./metrics');
const validateLinks = require('./validateLinks');
const process = require('process');
let router = process.argv[2]
let options = process.argv[3]+process.argv[4]
console.log(options)
if (options.trim() === 0) {
mdLinks(router)
.then(console.log)}
if (options.trim() == '--validate'){
mdLinks(router, options)
.then(console.log)
}
if (options == '--stats' || '--stats--validate'){
mdLinks(router, options)
.then((result)=> {
let metric = metrics(result , options)
console.log(metric)
return metric
})}
else { console.log('Sorry, that option is not valid');
console.log( 'you can use --validate , --stats , --stats --validate')}
// Leer argumentos parte de cli crear una funcion para cli que llame mdlinks validate y stats
// https://nodejs.org/en/knowledge/command-line/how-to-parse-command-line-arguments/
//node cli.js README.md --stats