Skip to content

Commit

Permalink
fix(cli): 小程序编译时对引用目录的错误提示
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Jun 10, 2018
1 parent a28a1e0 commit c6bd177
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/taro-cli/src/weapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,22 @@ function parseAst (type, ast, sourceFilePath, filePath) {
astPath.remove()
}
} else if (!valueExtname) {
const vpath = Util.resolveScriptPath(path.resolve(sourceFilePath, '..', value))
let vpath = Util.resolveScriptPath(path.resolve(sourceFilePath, '..', value))
const outputVpath = vpath.replace(sourceDir, outputDir)
const relativePath = path.relative(filePath, outputVpath)
let relativePath = path.relative(filePath, outputVpath)
if (vpath) {
if (!fs.existsSync(vpath)) {
Util.printLog(Util.pocessTypeEnum.ERROR, '引用文件', `文件 ${sourceFilePath} 中引用 ${value} 不存在!`)
} else {
if (fs.lstatSync(vpath).isDirectory()) {
if (fs.existsSync(path.join(vpath, 'index.js'))) {
vpath = path.join(vpath, 'index.js')
relativePath = path.join(relativePath, 'index.js')
} else {
Util.printLog(Util.pocessTypeEnum.ERROR, '引用目录', `文件 ${sourceFilePath} 中引用了目录 ${value}!`)
return
}
}
if (scriptFiles.indexOf(vpath) < 0) {
scriptFiles.push(vpath)
}
Expand Down

0 comments on commit c6bd177

Please sign in to comment.