1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function isOutputConfigArray(type) {
|
4 | return Array.isArray(type);
|
5 | }
|
6 | exports.isOutputConfigArray = isOutputConfigArray;
|
7 | function isConfiguredOutput(type) {
|
8 | return typeof type === 'object' && type['plugins'];
|
9 | }
|
10 | exports.isConfiguredOutput = isConfiguredOutput;
|
11 | function normalizeOutputParam(config) {
|
12 | if (isOutputConfigArray(config)) {
|
13 | return {
|
14 | documents: [],
|
15 | schema: [],
|
16 | plugins: config
|
17 | };
|
18 | }
|
19 | else if (isConfiguredOutput(config)) {
|
20 | return config;
|
21 | }
|
22 | else {
|
23 | throw new Error(`Invalid "generates" config!`);
|
24 | }
|
25 | }
|
26 | exports.normalizeOutputParam = normalizeOutputParam;
|
27 | function normalizeInstanceOrArray(type) {
|
28 | if (Array.isArray(type)) {
|
29 | return type;
|
30 | }
|
31 | else if (!type) {
|
32 | return [];
|
33 | }
|
34 | return [type];
|
35 | }
|
36 | exports.normalizeInstanceOrArray = normalizeInstanceOrArray;
|
37 | function normalizeConfig(config) {
|
38 | if (typeof config === 'string') {
|
39 | return [{ [config]: {} }];
|
40 | }
|
41 | else if (Array.isArray(config)) {
|
42 | return config.map(plugin => (typeof plugin === 'string' ? { [plugin]: {} } : plugin));
|
43 | }
|
44 | else if (typeof config === 'object') {
|
45 | return Object.keys(config).reduce((prev, pluginName) => [...prev, { [pluginName]: config[pluginName] }], []);
|
46 | }
|
47 | else {
|
48 | return [];
|
49 | }
|
50 | }
|
51 | exports.normalizeConfig = normalizeConfig;
|
52 |
|
\ | No newline at end of file |