@@ -185,8 +185,8 @@ const core = {
185
185
//自定义默认是否转义,默认为默认自动转义
186
186
escape : true ,
187
187
188
- baseSrcPath : __dirname ,
189
- baseDestPath : '' ,
188
+ basePath : process . cwd ( ) ,
189
+ cachePath : '' ,
190
190
191
191
defaultExtName : '.html' ,
192
192
@@ -234,17 +234,17 @@ const core = {
234
234
name += this . defaultExtName ;
235
235
}
236
236
237
- const baseDestPath = this . baseDestPath || path . join ( os . tmpdir ( ) , 'changba-template-cache' , getHash ( this . baseSrcPath ) ) ;
237
+ const cachePath = this . cachePath || path . join ( os . tmpdir ( ) , 'changba-template-cache' , getHash ( this . basePath ) ) ;
238
238
239
- const destFilename = path . join ( baseDestPath , getHash ( name + ( block === '' ? '' : ':' + block ) ) + extName ) ;
239
+ const destFilename = path . join ( cachePath , getHash ( name + ( block === '' ? '' : ':' + block ) ) + extName ) ;
240
240
241
241
// 先检查是否需要重编译
242
242
if ( ! this . _check ( destFilename ) ) {
243
243
return destFilename ;
244
244
}
245
245
246
246
// 先读取文件名
247
- const filename = path . join ( this . baseSrcPath , name ) ;
247
+ const filename = path . join ( this . basePath , name ) ;
248
248
// TODO: 可能需要先判断文件是否存在,并给出错误信息
249
249
let content = fs . readFileSync ( filename ) . toString ( ) ;
250
250
templateData . templates [ name ] = getFileTime ( filename ) ;
@@ -284,7 +284,7 @@ const core = {
284
284
for ( const key in templates ) {
285
285
const value = templates [ key ] ;
286
286
287
- const newTime = getFileTime ( path . join ( this . baseSrcPath , key ) ) ;
287
+ const newTime = getFileTime ( path . join ( this . basePath , key ) ) ;
288
288
if ( newTime > value ) {
289
289
// 文件有更新
290
290
return true ;
@@ -309,7 +309,7 @@ const core = {
309
309
name += this . defaultExtName ;
310
310
}
311
311
312
- const filename = path . join ( this . baseSrcPath , name ) ;
312
+ const filename = path . join ( this . basePath , name ) ;
313
313
let content = fs . readFileSync ( filename ) . toString ( ) ;
314
314
templateData . templates [ name ] = getFileTime ( filename ) ;
315
315
0 commit comments