2023-06-07 20:23:39 +08:00

30 lines
921 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const fs = require('fs')
const path = require('path')
const scanFiles = function(dir) {
var results = []
var list = fs.readdirSync(dir)
list.forEach(function(file) {
// 排除static静态目录可按你需求进行新增
// if (file === 'config.json') {
// return false
// }
const filePath = dir + '/' + file
var stat = fs.statSync(filePath)
if (stat && stat.isDirectory()) {
results = results.concat(scanFiles(filePath))
} else {
// 过滤后缀名(可按你需求进行新增)
// if (path.extname(filePath) === '.json') {
// results.push(path.resolve(__dirname, filePath))
// }
if (file === 'config.json') {
results.push(path.resolve(__dirname, filePath))
}
}
})
return results
}
module.exports = {
scanFiles
}