Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

loaders.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.loaders = void 0;
  6. /* eslint-disable @typescript-eslint/no-require-imports */
  7. let importFresh;
  8. const loadJs = function loadJs(filepath) {
  9. if (importFresh === undefined) {
  10. importFresh = require('import-fresh');
  11. }
  12. const result = importFresh(filepath);
  13. return result;
  14. };
  15. let parseJson;
  16. const loadJson = function loadJson(filepath, content) {
  17. if (parseJson === undefined) {
  18. parseJson = require('parse-json');
  19. }
  20. try {
  21. const result = parseJson(content);
  22. return result;
  23. } catch (error) {
  24. error.message = `JSON Error in ${filepath}:\n${error.message}`;
  25. throw error;
  26. }
  27. };
  28. let yaml;
  29. const loadYaml = function loadYaml(filepath, content) {
  30. if (yaml === undefined) {
  31. yaml = require('yaml');
  32. }
  33. try {
  34. const result = yaml.parse(content, {
  35. prettyErrors: true
  36. });
  37. return result;
  38. } catch (error) {
  39. error.message = `YAML Error in ${filepath}:\n${error.message}`;
  40. throw error;
  41. }
  42. };
  43. const loaders = {
  44. loadJs,
  45. loadJson,
  46. loadYaml
  47. };
  48. exports.loaders = loaders;
  49. //# sourceMappingURL=loaders.js.map