forked from Laboratoria/LIM015-md-links
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdlinks.js
29 lines (24 loc) Β· 826 Bytes
/
mdlinks.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
const api = require('./index.js');
const mdLinks = (route, options = {}) =>
new Promise ((resolve, reject) => {
if (!api.existPath(route)) {
reject('This path does not exist');
} else {
const allRoutes = api.checkPath(route);
let arrayAllRoutes = [];
allRoutes.forEach(element => {
const validLinks = api.getAllLinks(element);
arrayAllRoutes = arrayAllRoutes.concat(validLinks)
})
if (!(options.validate)) {
resolve(arrayAllRoutes);
} else {
const statusLinks = api.validateLinks(arrayAllRoutes);
resolve(statusLinks);
}
}
});
module.exports = {
mdLinks
}
//console.log(mdLinks('C:\\Users\\LORD\\Desktop\\mdlinks-prueba\\LIM015-md-links\\prueba\\test.md', { validate:true }));