fix: container panic when discover not exists

This commit is contained in:
Lin, Hung-Shin committed 2023-11-22 10:23:47 +08:00
1 parent d19b32c6d1
commit ba641ca222
1 file changed
+4
+4
View File
@@ -34,12 +34,16 @@ async function collectFilesInfo(inputPath, level = 0, hiddenFiles = false) {
async function discoverFiles(argv) { async function discoverFiles(argv) {
const targetPath = argv._.length < 2 ? ['.'] : argv._.slice(1) const targetPath = argv._.length < 2 ? ['.'] : argv._.slice(1)
try {
const result = await Promise.all( const result = await Promise.all(
targetPath targetPath
.map((p) => path.resolve(process.cwd(), p)) .map((p) => path.resolve(process.cwd(), p))
.map((p) => collectFilesInfo(p, 0, argv.a || argv.all)) .map((p) => collectFilesInfo(p, 0, argv.a || argv.all))
) )
return { discover: result.flat() } return { discover: result.flat() }
} catch (err) {
return {}
}
} }
module.exports = discoverFiles module.exports = discoverFiles