Skip to content

Commit e247aad

Browse files
committed
update
1 parent 9c520cc commit e247aad

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

.eslintrc

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
{
2+
"parserOptions": {
3+
"ecmaVersion": 2018,
4+
"sourceType": "module",
5+
"ecmaFeatures": {
6+
"jsx": false
7+
}
8+
},
29
"env": {
3-
"browser": true,
410
"node": true,
511
"es6": true,
612
"jasmine": true,
@@ -41,17 +47,6 @@
4147
"key-spacing": [1, {"beforeColon": false, "afterColon": true, "mode": "minimum"}],
4248
"space-in-parens": [1, "never"],
4349
"prefer-const": 2,
44-
"no-control-regex": 0,
45-
"semi": "warn"
46-
},
47-
"parserOptions": {
48-
"ecmaVersion": 6,
49-
"sourceType": "module",
50-
"ecmaFeatures": {
51-
"jsx": false
52-
}
53-
},
54-
"globals": {
55-
"atom": true
50+
"no-control-regex": 0
5651
}
5752
}

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ const core = {
185185
//自定义默认是否转义,默认为默认自动转义
186186
escape: true,
187187

188-
baseSrcPath: __dirname,
189-
baseDestPath: '',
188+
basePath: process.cwd(),
189+
cachePath: '',
190190

191191
defaultExtName: '.html',
192192

@@ -234,17 +234,17 @@ const core = {
234234
name += this.defaultExtName;
235235
}
236236

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));
238238

239-
const destFilename = path.join(baseDestPath, getHash(name + (block === '' ? '' : ':' + block)) + extName);
239+
const destFilename = path.join(cachePath, getHash(name + (block === '' ? '' : ':' + block)) + extName);
240240

241241
// 先检查是否需要重编译
242242
if (!this._check(destFilename)) {
243243
return destFilename;
244244
}
245245

246246
// 先读取文件名
247-
const filename = path.join(this.baseSrcPath, name);
247+
const filename = path.join(this.basePath, name);
248248
// TODO: 可能需要先判断文件是否存在,并给出错误信息
249249
let content = fs.readFileSync(filename).toString();
250250
templateData.templates[name] = getFileTime(filename);
@@ -284,7 +284,7 @@ const core = {
284284
for (const key in templates) {
285285
const value = templates[key];
286286

287-
const newTime = getFileTime(path.join(this.baseSrcPath, key));
287+
const newTime = getFileTime(path.join(this.basePath, key));
288288
if (newTime > value) {
289289
// 文件有更新
290290
return true;
@@ -309,7 +309,7 @@ const core = {
309309
name += this.defaultExtName;
310310
}
311311

312-
const filename = path.join(this.baseSrcPath, name);
312+
const filename = path.join(this.basePath, name);
313313
let content = fs.readFileSync(filename).toString();
314314
templateData.templates[name] = getFileTime(filename);
315315

0 commit comments

Comments
 (0)