1 | const walk = require('walk');
|
2 |
|
3 | const config = require('./config');
|
4 |
|
5 |
|
6 | const walker = walk.walk('./vdp');
|
7 | walker.on('file', function (root, fileStats, next) {
|
8 | const ext = path.extname(fileStats.name);
|
9 | const basename = fileStats.name;
|
10 | if (ext === '.js') {
|
11 | if (basename.indexOf('vendor') === 0) {
|
12 | next();
|
13 | } else {
|
14 | data.js.push(basename);
|
15 | }
|
16 | } else if (ext === '.css') {
|
17 | data.css.push(basename);
|
18 | }
|
19 |
|
20 | next();
|
21 | });
|
22 |
|
23 |
|
24 | walker.on('end', () => {
|
25 | data.js = JSON.stringify(data.js);
|
26 | data.css = JSON.stringify(data.css);
|
27 |
|
28 | const result = tpl.replace(/<%([^%>]+)?%>/g, function(s0, s1){
|
29 | return data[s1];
|
30 | });
|
31 |
|
32 | fs.writeFile('./vdp/lib.js', result, (err) => {
|
33 | if(err) throw err;
|
34 | console.log('tolib success!');
|
35 | });
|
36 |
|
37 |
|
38 | }); |
\ | No newline at end of file |