修复异常

This commit is contained in:
aixianling
2022-05-12 11:26:36 +08:00
parent 5a4c6103e6
commit f0babad995
2 changed files with 31 additions and 13 deletions

View File

@@ -54,6 +54,21 @@ const findApp = (dir, cb) => {
}) || [])
})
}
const findPages = (dir, cb) => {
fsExtra.ensureDirSync(dir)
return readdir(dir).then(apps => {
return Promise.all(apps.map(e => {
let cPath = path.join(dir, e)
return stat(cPath).then(state => {
if (state.isDirectory()) {
return findPages(cPath, cb)
} else if (state.isFile()) {
cb && cb(cPath)
}
})
}) || [])
})
}
const copyFiles = (dir, source = 'src/mods') => {
chalkTag.info(`开始扫描${source}...`)
return new Promise(resolve => {
@@ -67,4 +82,4 @@ const copyFiles = (dir, source = 'src/mods') => {
})
})
}
module.exports = {findApp, chalkTag, fsExtra, copyFiles, fs, path}
module.exports = {findApp, chalkTag, fsExtra, copyFiles, fs, path, findPages}