讀取資料夾
fs.readdirSync('./')
判斷檔案型別
fs.statSync(item).isDirectory()
路徑拼接
path.resolve(dir, item)
封裝
function deepGetFile(dir) {
let backList = []
let list = fs.readdirSync(dir)
for (let index in list) {
let item = path.resolve(dir, list[index])
if (fs.statSync(item).isDirectory()) {
backList = backList.concat(deepGetFile(item))
} else {
backList.push(item)
}
}
return backList
}