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 | var _a;
|
39 | if (typeof config === 'string') {
|
40 | return [(_a = {}, _a[config] = {}, _a)];
|
41 | }
|
42 | else if (Array.isArray(config)) {
|
43 | return config.map(function (plugin) {
|
44 | var _a;
|
45 | return (typeof plugin === 'string' ? (_a = {}, _a[plugin] = {}, _a) : plugin);
|
46 | });
|
47 | }
|
48 | else if (typeof config === 'object') {
|
49 | return Object.keys(config).reduce(function (prev, pluginName) {
|
50 | var _a;
|
51 | return prev.concat([(_a = {}, _a[pluginName] = config[pluginName], _a)]);
|
52 | }, []);
|
53 | }
|
54 | else {
|
55 | return [];
|
56 | }
|
57 | }
|
58 | exports.normalizeConfig = normalizeConfig;
|
59 |
|
\ | No newline at end of file |