source: frontend/node_modules/@svgr/core/lib/config.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.2 KB
Line 
1"use strict";
2
3exports.__esModule = true;
4exports.resolveConfig = resolveConfig;
5exports.resolveConfigFile = resolveConfigFile;
6exports.loadConfig = loadConfig;
7exports.DEFAULT_CONFIG = void 0;
8
9var _cosmiconfig = require("cosmiconfig");
10
11const DEFAULT_CONFIG = {
12 dimensions: true,
13 expandProps: 'end',
14 icon: false,
15 native: false,
16 typescript: false,
17 prettier: true,
18 prettierConfig: null,
19 memo: false,
20 ref: false,
21 replaceAttrValues: null,
22 svgProps: null,
23 svgo: true,
24 svgoConfig: null,
25 template: null,
26 titleProp: false,
27 runtimeConfig: true,
28 plugins: null,
29 namedExport: 'ReactComponent'
30};
31exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
32const explorer = (0, _cosmiconfig.cosmiconfig)('svgr', {
33 sync: true,
34 cache: true,
35 rcExtensions: true
36});
37const explorerSync = (0, _cosmiconfig.cosmiconfigSync)('svgr', {
38 sync: true,
39 cache: true,
40 rcExtensions: true
41});
42
43async function resolveConfig(searchFrom, configFile) {
44 if (configFile == null) {
45 const result = await explorer.search(searchFrom);
46 return result ? result.config : null;
47 }
48
49 const result = await explorer.load(configFile);
50 return result ? result.config : null;
51}
52
53resolveConfig.sync = (searchFrom, configFile) => {
54 if (configFile == null) {
55 const result = explorerSync.search(searchFrom);
56 return result ? result.config : null;
57 }
58
59 const result = explorerSync.load(configFile);
60 return result ? result.config : null;
61};
62
63async function resolveConfigFile(filePath) {
64 const result = await explorer.search(filePath);
65 return result ? result.filepath : null;
66}
67
68resolveConfigFile.sync = filePath => {
69 const result = explorerSync.search(filePath);
70 return result ? result.filepath : null;
71};
72
73async function loadConfig({
74 configFile,
75 ...baseConfig
76}, state = {}) {
77 const rcConfig = state.filePath && baseConfig.runtimeConfig !== false ? await resolveConfig(state.filePath, configFile) : {};
78 return { ...DEFAULT_CONFIG,
79 ...rcConfig,
80 ...baseConfig
81 };
82}
83
84loadConfig.sync = ({
85 configFile,
86 ...baseConfig
87}, state = {}) => {
88 const rcConfig = state.filePath && baseConfig.runtimeConfig !== false ? resolveConfig.sync(state.filePath, configFile) : {};
89 return { ...DEFAULT_CONFIG,
90 ...rcConfig,
91 ...baseConfig
92 };
93};
Note: See TracBrowser for help on using the repository browser.