过滤scripts目录下的子目录

This commit is contained in:
hanhh 2021-06-20 22:05:43 +08:00
parent 4f5f49611c
commit 4dc69c2779

View File

@ -18,9 +18,13 @@ export default (app: Router) => {
const fileList = fs.readdirSync(config.scriptPath, 'utf-8'); const fileList = fs.readdirSync(config.scriptPath, 'utf-8');
res.send({ res.send({
code: 200, code: 200,
data: fileList.map((x) => { data: fileList
return { title: x, value: x, key: x }; .filter((x) => {
}), return !fs.lstatSync(config.scriptPath + x).isDirectory();
})
.map((x) => {
return { title: x, value: x, key: x };
}),
}); });
} catch (e) { } catch (e) {
logger.error('🔥 error: %o', e); logger.error('🔥 error: %o', e);