-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
48 lines (38 loc) · 1.13 KB
/
index.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
36
37
38
39
40
41
42
43
44
45
46
47
48
var fs=require('fs');
var fsi = require('fs-filesysteminfo');
var rootDirs=['git','javascript','设计模式'];
var bookItems=[];
var tempStr='';
var dtNow=new Date();
var getFileList=function(rootPath){
var args=arguments;
var fsiObj = new fsi.FileInfo(rootPath);
if(fsiObj.flags.isDirectory){
//tempStr+='—';
bookItems.push('## '+tempStr+fsiObj.name+' ##');
fs.readdirSync(rootPath).forEach(file=>{
args.callee(rootPath+'/'+file);
});
//tempStr=tempStr.substr(1);
}else{
bookItems.push(fsiObj.name);
}
};
fs.readdirSync('./').forEach(file=>{
if(rootDirs.indexOf(file)==-1) return;
getFileList(file);
});
//更新readme.md
fs.writeFile('./readme.md', `
# 简介
这里存放着本人平时以思维导图形式整理的相关资料信息,如有引用和转载,请注明出处。
# XMind
需要安装免费的[XMind思维导图软件](http://www.xmindchina.net/),才能打开相应的文件。
----------
# 目录
${bookItems.join('\r\n\r\n')}
----------
本目录更新时间:${dtNow}
`, null, function () {
console.log('updated readme.md')
});