@@ -65,6 +65,22 @@ exec('rm -rf .deploy');
6565// 生成 项目所需的文件
6666CreateDatajs ( './.deploy/js/dt.js' , function ( dt_path , arr ) {
6767
68+
69+ // 拷贝 favicon.ico 文件 start
70+ var filetopath = path . join ( process . cwd ( ) , '/template/img/favicon.ico' ) ;
71+ var topath = '.deploy/img/favicon.ico'
72+
73+ mkdirsSync ( path . join ( process . cwd ( ) , '.deploy/img/' ) ) ;
74+ // 创建读取流
75+ readable = fs . createReadStream ( filetopath ) ;
76+ // 创建写入流
77+ writable = fs . createWriteStream ( topath ) ;
78+ // 通过管道来传输流
79+ readable . pipe ( writable ) ;
80+ console . log ( success ( " → " ) + topath + '' ) ;
81+ // 拷贝 favicon.ico 文件 end
82+
83+
6884 CreateJS ( '/template/js/index.js' , '/.deploy/js/index.js' )
6985
7086 CreateStyl ( '/template/styl/index.styl' , '/.deploy/css/index.css' )
@@ -92,37 +108,41 @@ CreateDatajs('./.deploy/js/dt.js',function(dt_path,arr){
92108
93109} )
94110
111+ function copy ( src , dst ) {
112+ fs . createReadStream ( src ) . pipe ( fs . createWriteStream ( dst ) ) ;
113+ }
95114
96- // // 监听实时编译
97- // watch.watchTree(path.join(path.dirname(__dirname),'/'), function (f, curr, prev) {
98- // if (typeof f == "object" && prev === null && curr === null) {
99- // console.log(success(" → :watching ") + '/template/');
100- // // Finished walking the tree
101- // } else if (prev === null) {
102115
103- // // f is a new file
104- // } else if (curr.nlink === 0) {
105- // // f was removed
106- // } else {
116+ // 监听实时编译
117+ watch . watchTree ( path . join ( path . dirname ( __dirname ) , '/' ) , function ( f , curr , prev ) {
118+ if ( typeof f == "object" && prev === null && curr === null ) {
119+ console . log ( success ( " → :watching " ) + '/template/' ) ;
120+ // Finished walking the tree
121+ } else if ( prev === null ) {
122+
123+ // f is a new file
124+ } else if ( curr . nlink === 0 ) {
125+ // f was removed
126+ } else {
107127
108- // if(/\.styl$/.test(f)){
109- // CreateStyl('/template/styl/index.styl','/.deploy/css/index.css')
110- // }else if(/\.js$/.test(f)){
128+ if ( / \. s t y l $ / . test ( f ) ) {
129+ CreateStyl ( '/template/styl/index.styl' , '/.deploy/css/index.css' )
130+ } else if ( / \. j s $ / . test ( f ) ) {
111131
112- // CreateJS('/template/js/index.js','/.deploy/js/index.js')
132+ CreateJS ( '/template/js/index.js' , '/.deploy/js/index.js' )
113133
114- // }else if(/\.ejs$/.test(f)){
115- // // 首页生成
116- // ReadTmpToHTML('/template/index.ejs','/.deploy/index.html');
117- // ReadTmpToHTML('/template/list.ejs','/.deploy/list.html');
134+ } else if ( / \. e j s $ / . test ( f ) ) {
135+ // 首页生成
136+ ReadTmpToHTML ( '/template/index.ejs' , '/.deploy/index.html' ) ;
137+ ReadTmpToHTML ( '/template/list.ejs' , '/.deploy/list.html' ) ;
118138
119- // }else if(/\.md$/.test(f)){
120- // var mdp = f.replace(path_root,'');
121- // var dep = path.join('/.deploy/',mdp);
122- // ReadTmpToHTML('/template/details.ejs',dep.replace('.md','.html'),mdp);
123- // }
124- // }
125- // })
139+ } else if ( / \. m d $ / . test ( f ) ) {
140+ var mdp = f . replace ( path_root , '' ) ;
141+ var dep = path . join ( '/.deploy/' , mdp ) ;
142+ ReadTmpToHTML ( '/template/details.ejs' , dep . replace ( '.md' , '.html' ) , mdp ) ;
143+ }
144+ }
145+ } )
126146
127147
128148function CreateJS ( from_path , to_path ) {
0 commit comments