-
Notifications
You must be signed in to change notification settings - Fork 247
/
fnIndex.js
executable file
·35 lines (34 loc) · 975 Bytes
/
fnIndex.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
28
29
30
31
32
33
34
35
let fs = require('fs');
let fns=[];
fs.readFile('./src/ec-do-3.0.0-beta.1.js', (err, data) => {
if (err) {
//如 果 出 错, 输 出 错 误 日 志, 并 给 客 户 端 返 回“ Server Error”
console.error(err);
}
else {
let md="";
let obj=new Function(data.toString().replace('let','let _ecObj=')+';return _ecObj')();
Object.keys(obj).forEach((item,index)=>{
fns.push({
index:index,
name:item
})
})
}
})
fs.readFile('./README.md', (err, data) => {
if (err) {
console.error(err);
}
else {
let _data=data.toString().split('\r\n');
let i=1;
_data.forEach((item,index)=>{
if(/#{3}\s([0-9]+)/.test(item)){
_data[index]=item.replace(/#{3}\s([0-9]+)/,'### '+i);
i++;
}
})
fs.writeFileSync("./README.md", _data.join('\r\n'));
}
})