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