UNPKG

1.26 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6/* eslint-disable no-param-reassign, max-len */
7
8// Validates and defaults the options
9function validateOptions(options) {
10 // Default options to our preferred value
11 options.dest = options.dest || 'carte-blanche';
12 // Remove a prefixed slash from the dest option, i.e. /test/ -> test/
13 options.dest = options.dest.replace(/^\/|\\/gi, '');
14 // HACK: Webpack can embed this regex verbatim and the .? makes it not insert a comment terminator
15 options.filter = options.filter || /(\/[A-Z][a-zA-Z]*.?\/index|\/[A-Z][a-zA-Z]*)\.(jsx?|es6|react\.jsx?)$/;
16
17 // Assert that the componentRoot option was specified
18 if (!options.componentRoot) {
19 throw new Error('You need to specify where your components are in the "componentRoot" option!\n\n');
20 }
21
22 // Assert that the plugins option is an array if specified
23 if (options.plugins && !Array.isArray(options.plugins)) {
24 throw new Error('The "plugins" option needs to be an array!\n\n');
25 }
26
27 // Assert that the files option is an array if specified
28 if (options.files && !Array.isArray(options.files)) {
29 throw new Error('The "files" option needs to be an array!\n\n');
30 }
31}
32
33exports.default = validateOptions;
\No newline at end of file