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");

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2021-11-09
  • 2021-10-29
  • 2021-05-26
猜你喜欢
  • 2021-09-16
  • 2021-12-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-01-10
相关资源
相似解决方案