UNPKG

diginext-utils

Version:
39 lines (38 loc) 1.44 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); function getAllFiles(dirPath, skipDotStart) { // const list = []; const files = fs_1.default.readdirSync(dirPath); files.forEach(function (file) { if (!/^(node_modules|_next|\.next|\.git)/.test(file)) { if (skipDotStart) { if (!/^\..*/.test(file)) { const newPath = path_1.default.join(dirPath, "/", file).replace(/\\/g, "/"); if (fs_1.default.statSync(newPath).isDirectory()) { list.push(...getAllFiles(newPath)); } else { list.push(newPath); } } } else { const newPath = path_1.default.join(dirPath, "/", file).replace(/\\/g, "/"); if (fs_1.default.statSync(newPath).isDirectory()) { list.push(...getAllFiles(newPath)); } else { list.push(newPath); } } } }); return list; } exports.default = getAllFiles;