source: trip-planner-front/node_modules/cosmiconfig/dist/loaders.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.loaders = void 0;
7
8/* eslint-disable @typescript-eslint/no-require-imports */
9let importFresh;
10
11const loadJs = function loadJs(filepath) {
12 if (importFresh === undefined) {
13 importFresh = require('import-fresh');
14 }
15
16 const result = importFresh(filepath);
17 return result;
18};
19
20let parseJson;
21
22const loadJson = function loadJson(filepath, content) {
23 if (parseJson === undefined) {
24 parseJson = require('parse-json');
25 }
26
27 try {
28 const result = parseJson(content);
29 return result;
30 } catch (error) {
31 error.message = `JSON Error in ${filepath}:\n${error.message}`;
32 throw error;
33 }
34};
35
36let yaml;
37
38const loadYaml = function loadYaml(filepath, content) {
39 if (yaml === undefined) {
40 yaml = require('yaml');
41 }
42
43 try {
44 const result = yaml.parse(content, {
45 prettyErrors: true
46 });
47 return result;
48 } catch (error) {
49 error.message = `YAML Error in ${filepath}:\n${error.message}`;
50 throw error;
51 }
52};
53
54const loaders = {
55 loadJs,
56 loadJson,
57 loadYaml
58};
59exports.loaders = loaders;
60//# sourceMappingURL=loaders.js.map
Note: See TracBrowser for help on using the repository browser.