forked from Laboratoria/MEX008-FE-md-link
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
executable file
·45 lines (39 loc) · 1.22 KB
/
index.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
#!/usr/bin/env node
const readFileMd = require('./modules/readFileMd');
const typeOfFile = require('./modules/getFileMd.js');
const searchLinks = require('./modules/getLinks.js');
const getStats = require('./modules/stats');
const getValidation = require('./modules/validateLinks');
const mdLinks =(pathFile, validate,stats)=>{
return new Promise((resolve => {
if(typeOfFile(pathFile)){
readFileMd(pathFile)
.then((data) => {
return searchLinks(data);
})
.then(res => {
if (process.argv[3] == null && process.argv[4] == null){
console.log(res);
}
else if(validate==="validate" && stats === "stats") {
console.log(`${getValidation(res)}
Total: ${res.length}
Unique: ${getStats(res)}`)
}
else if(validate === "validate"){
console.log(getValidation(res));
}
else if(validate === "stats"){
console.log(`Total: ${res.length}
Unique: ${getStats (res)}`);
}
else{
console.log("error las banderas son validate o stats")
}
})
} else {
console.log("Archivo no valido");
}
}))
};
mdLinks(process.argv[2],process.argv[3],process.argv[4]);