recursive-readdir-sync.js 842 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.recursiveReadDirSync = recursiveReadDirSync;
  6. var _fs = _interopRequireDefault(require("fs"));
  7. var _path = require("path");
  8. function _interopRequireDefault(obj) {
  9. return obj && obj.__esModule ? obj : {
  10. default: obj
  11. };
  12. }
  13. function recursiveReadDirSync(dir, arr = [], rootDir = dir) {
  14. const result = _fs.default.readdirSync(dir);
  15. result.forEach((part)=>{
  16. const absolutePath = (0, _path).join(dir, part);
  17. const pathStat = _fs.default.statSync(absolutePath);
  18. if (pathStat.isDirectory()) {
  19. recursiveReadDirSync(absolutePath, arr, rootDir);
  20. return;
  21. }
  22. arr.push(absolutePath.replace(rootDir, ""));
  23. });
  24. return arr;
  25. }
  26. //# sourceMappingURL=recursive-readdir-sync.js.map