Skip to content

Commit

Permalink
relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieyang committed Feb 26, 2016
1 parent c9895ba commit 32a3b18
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ module.exports = function () {
options.output = process.cwd() + '/.temp';

var tmod = new Tmod(__dirname, options);
// 不明白为什么要在构造函数里检查base/package.json的tmod版本,而且还写死了dependencies不能用devDependencies,
// 是为了阻止别人做封装么?
tmod.base = process.cwd().replace(/\\/g, '/');

var output = tmod._compile(this.resourcePath.replace(/\\/g, "/"));
Expand All @@ -27,12 +25,8 @@ module.exports = function () {

//转化所有子模板为require
var requires = output.requires.map(function (req) {
var tmpPath = path.relative(path.dirname(output.sourceFile), req + extname).replace(/\\/g, '/');

//如果include的文件是当前目录下的文件,需要加"./"前缀,否则无法找到该文件,你懂的
tmpPath.indexOf("/") == -1 && (tmpPath = "./" + tmpPath);

return "require('" + tmpPath + "');";
// 需要加"./"前缀,否则无法找到该文件,你懂的
return "require('./" + path.relative(path.dirname(output.sourceFile), req + extname).replace(/\\/g, '/') + "');";
}).join('');

clearTimeout(timer);
Expand Down

0 comments on commit 32a3b18

Please sign in to comment.