1 | const fs = require('fs');
|
2 | const path = require('path');
|
3 | const walk = require('walk');
|
4 | const config = require('./config');
|
5 | const md = require('./lib/marked');
|
6 |
|
7 | const walker = walk.walk(config.root);
|
8 | walker.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 |
|
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 |
|
25 | walker.on('end', () => {
|
26 |
|
27 |
|
28 | });
|
29 |
|
30 | walker.on('error', (e) => {
|
31 | console.log(e);
|
32 | }) |
\ | No newline at end of file |