UNPKG

@kiwigdc/kiwilaunch

Version:
48 lines (47 loc) 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RecursiveFolderFile = void 0; const path = require("path"); const fs = require("fs"); class RecursiveFolderFile { static getAllFiles(dirPath, arrayOfFiles = [], typeFile, excludes) { var files = fs.readdirSync(dirPath); arrayOfFiles = arrayOfFiles || []; files.forEach(function (file) { if (excludes == undefined) { if (fs.statSync(path.join(dirPath, file)).isDirectory()) { arrayOfFiles = RecursiveFolderFile.getAllFiles(dirPath + "/" + file, arrayOfFiles, typeFile); } else if (fs.statSync(path.join(dirPath, file)).isFile()) { const pathFile = path.join(dirPath, file); if (typeFile == undefined) { arrayOfFiles.push(pathFile); } else { if (path.extname(pathFile) == typeFile) { arrayOfFiles.push(pathFile); } } } } else if (!excludes.includes(path.join(dirPath, file))) { if (fs.statSync(path.join(dirPath, file)).isDirectory()) { arrayOfFiles = RecursiveFolderFile.getAllFiles(dirPath + "/" + file, arrayOfFiles, typeFile, excludes); } else if (fs.statSync(path.join(dirPath, file)).isFile()) { const pathFile = path.join(dirPath, file); if (typeFile == undefined) { arrayOfFiles.push(pathFile); } else { if (path.extname(pathFile) == typeFile) { arrayOfFiles.push(pathFile); } } } } }); return arrayOfFiles; } } exports.RecursiveFolderFile = RecursiveFolderFile;