UNPKG

@backtrace/sourcemap-tools

Version:
42 lines 2.07 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FileFinder = void 0; const fs_1 = __importDefault(require("fs")); const path_1 = __importDefault(require("path")); class FileFinder { find(dir, options) { return __awaiter(this, void 0, void 0, function* () { const result = []; const files = yield fs_1.default.promises.readdir(dir); for (const file of files) { const fullPath = path_1.default.resolve(dir, file); const stat = yield fs_1.default.promises.stat(fullPath); if (stat.isDirectory()) { if (options === null || options === void 0 ? void 0 : options.recursive) { const innerFindResult = yield this.find(fullPath, options); files.push(...innerFindResult); } continue; } if (!(options === null || options === void 0 ? void 0 : options.match) || fullPath.match(options.match)) { result.push(fullPath); } } return result; }); } } exports.FileFinder = FileFinder; //# sourceMappingURL=FileFinder.js.map