get-resources.js 988 B

123456789101112131415161718192021
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getResources = void 0;
  4. const tslib_1 = require("tslib");
  5. const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
  6. const util_1 = (0, tslib_1.__importDefault)(require("util"));
  7. const match_files_1 = require("./match-files");
  8. const resolve_import_url_1 = require("./resolve-import-url");
  9. const getResources = async (ctx, options) => {
  10. const { resolveUrl } = options;
  11. const files = await (0, match_files_1.matchFiles)(ctx, options);
  12. files.forEach(file => ctx.dependency(file));
  13. const resources = await Promise.all(files.map(async (file) => {
  14. const content = await util_1.default.promisify(fs_1.default.readFile)(file, 'utf8');
  15. const resource = { file, content };
  16. return resolveUrl ? (0, resolve_import_url_1.resolveImportUrl)(ctx, resource) : resource;
  17. }));
  18. return resources;
  19. };
  20. exports.getResources = getResources;
  21. //# sourceMappingURL=get-resources.js.map