UNPKG

687 BJavaScriptView Raw
1const fs = require('fs');
2const path = require('path');
3const walk = require('walk');
4const config = require('./config');
5const md = require('./lib/marked');
6
7const walker = walk.walk(config.root);
8walker.on('file', function (root, fileStats, next) {
9 const basename = fileStats.name;
10 const ext = path.extname(basename);
11
12 const file = path.resolve(__dirname, root + '/' + basename);
13 // console.log(file);
14 if (ext === '.md') {
15 const txt = fs.readFileSync(file, 'utf-8');
16 const res = md(txt);
17 console.log(res);
18
19 }
20
21 next();
22});
23
24
25walker.on('end', () => {
26
27 // console.log('end');
28});
29
30walker.on('error', (e) => {
31 console.log(e);
32})
\No newline at end of file