Skip to content

Commit

Permalink
fix(taro): 增加递归查找中止条件,修正拼写错误 (#5045)
Browse files Browse the repository at this point in the history
  • Loading branch information
pengzhouhu authored and luckyadam committed Dec 26, 2019
1 parent ba5902a commit d0ca0a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/taro-cli/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ export function recursiveFindNodeModules (filePath: string): string {
if (fs.existsSync(nodeModules)) {
return nodeModules
}
if (dirname.split(path.sep).length <= 1) {
printLog(processTypeEnum.ERROR, `在${dirname}目录下`, `未找到node_modules文件夹,请先安装相关依赖库!`)
return nodeModules
}
return recursiveFindNodeModules(dirname)
}

Expand Down
8 changes: 4 additions & 4 deletions packages/taro-mini-runner/src/plugins/MiniPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export default class MiniPlugin {
if (!hasPageIn) {
const pagePath = resolveScriptPath(path.join(this.sourceDir, pageItem))
const templatePath = this.getTemplatePath(pagePath)
const isNative = this.isNativePageORComponent(templatePath, fs.readFileSync(pagePath).toString())
const isNative = this.isNativePageOrComponent(templatePath, fs.readFileSync(pagePath).toString())
this.pages.add({
name: pageItem,
path: pagePath,
Expand Down Expand Up @@ -448,7 +448,7 @@ export default class MiniPlugin {
...appPages.map(item => {
const pagePath = resolveScriptPath(path.join(this.sourceDir, item))
const pageTemplatePath = this.getTemplatePath(pagePath)
const isNative = this.isNativePageORComponent(pageTemplatePath, fs.readFileSync(pagePath).toString())
const isNative = this.isNativePageOrComponent(pageTemplatePath, fs.readFileSync(pagePath).toString())
return { name: item, path: pagePath, isNative }
})
])
Expand Down Expand Up @@ -536,7 +536,7 @@ export default class MiniPlugin {
})
}

isNativePageORComponent (templatePath, jsContent) {
isNativePageOrComponent (templatePath, jsContent) {
return fs.existsSync(templatePath) && jsContent.indexOf(taroJsFramework) < 0
}

Expand Down Expand Up @@ -688,7 +688,7 @@ export default class MiniPlugin {
if (fs.existsSync(componentPath) && !Array.from(this.components).some(item => item.path === componentPath)) {
const componentName = this.getComponentName(componentPath)
const componentTempPath = this.getTemplatePath(componentPath)
const isNative = this.isNativePageORComponent(componentTempPath, fs.readFileSync(componentPath).toString())
const isNative = this.isNativePageOrComponent(componentTempPath, fs.readFileSync(componentPath).toString())
const componentObj = { name: componentName, path: componentPath, isNative }
this.components.add(componentObj)
this.getComponents(compiler, new Set([componentObj]), false)
Expand Down

0 comments on commit d0ca0a0

Please sign in to comment.