提交 a2335b21 编写于 作者: fxy060608's avatar fxy060608

fix(cli): easycom

上级 c3dbde6a
...@@ -336,11 +336,16 @@ let uniAutoImportScanComponents = [] ...@@ -336,11 +336,16 @@ let uniAutoImportScanComponents = []
let uniQuickAppAutoImportScanComponents = false let uniQuickAppAutoImportScanComponents = false
const isDirectory = source => fs.lstatSync(source).isDirectory()
function getAutoComponentsByDir (componentsPath, absolute = false) { function getAutoComponentsByDir (componentsPath, absolute = false) {
const components = {} const components = {}
try { try {
fs.readdirSync(componentsPath).forEach(name => { fs.readdirSync(componentsPath).forEach(name => {
const folder = path.resolve(componentsPath, name) const folder = path.resolve(componentsPath, name)
if (!isDirectory(folder)) {
return
}
const importDir = absolute ? normalizePath(folder) : `@/components/${name}` const importDir = absolute ? normalizePath(folder) : `@/components/${name}`
// 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确) // 读取文件夹文件列表,比对文件名(fs.existsSync在大小写不敏感的系统会匹配不准确)
const files = fs.readdirSync(folder) const files = fs.readdirSync(folder)
...@@ -350,7 +355,9 @@ function getAutoComponentsByDir (componentsPath, absolute = false) { ...@@ -350,7 +355,9 @@ function getAutoComponentsByDir (componentsPath, absolute = false) {
components[`^${name}$`] = `${importDir}/${name}.nvue` components[`^${name}$`] = `${importDir}/${name}.nvue`
} }
}) })
} catch (e) {} } catch (e) {
console.log(e)
}
return components return components
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册