UNPKG

@mometa/materials-resolver

Version:
33 lines 1.78 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()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.materials = void 0; const search_core_1 = require("../utils/search-core"); const resolve_async_config_1 = require("../utils/resolve-async-config"); const path_1 = require("path"); const sorted_globby_1 = require("../utils/sorted-globby"); const to_array_1 = require("../utils/to-array"); function materials(findDirs, cwd) { return __awaiter(this, void 0, void 0, function* () { const list = []; const dirs = yield (0, sorted_globby_1.sortedGlobby)(findDirs, cwd); yield Promise.all(dirs.map((dir) => __awaiter(this, void 0, void 0, function* () { dir = (0, path_1.resolve)(cwd || '', dir); const d = yield search_core_1.materialExplorer.search(dir); if (!(d === null || d === void 0 ? void 0 : d.isEmpty)) { list.push(...(0, to_array_1.flatten)(yield (0, resolve_async_config_1.resolveAsyncConfig)(d.config))); } }))); return list; }); } exports.materials = materials; //# sourceMappingURL=materials.js.map