UNPKG

1.43 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3function isOutputConfigArray(type) {
4 return Array.isArray(type);
5}
6exports.isOutputConfigArray = isOutputConfigArray;
7function isConfiguredOutput(type) {
8 return typeof type === 'object' && type['plugins'];
9}
10exports.isConfiguredOutput = isConfiguredOutput;
11function 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}
26exports.normalizeOutputParam = normalizeOutputParam;
27function normalizeInstanceOrArray(type) {
28 if (Array.isArray(type)) {
29 return type;
30 }
31 else if (!type) {
32 return [];
33 }
34 return [type];
35}
36exports.normalizeInstanceOrArray = normalizeInstanceOrArray;
37function 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 {
49 return [];
50 }
51}
52exports.normalizeConfig = normalizeConfig;
53//# sourceMappingURL=helpers.js.map
\No newline at end of file