nodejs 读取目前下所有文件
作者:互联网
var fs = require('fs');
var join = require('path').join;
function getJsonFiles(jsonPath) {
let jsonFiles = [];
function findJsonFile(path) {
let files = fs.readdirSync(path);
files.forEach(function (item, index) {
let fPath = join(path, item);
let stat = fs.statSync(fPath);
if (stat.isDirectory() === true) {
findJsonFile(fPath);
}
if (stat.isFile() === true) {
jsonFiles.push(fPath);
}
});
}
findJsonFile(jsonPath);
console.log(jsonFiles);
}
getJsonFiles("test");
标签:function,文件,fs,读取,nodejs,fPath,let,findJsonFile,path 来源: https://www.cnblogs.com/daysme/p/11231116.html