You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

24 lines
614 B

"use strict";
module.exports = function prepareOptions(options, argv) {
argv = argv || {};
options = handleExport(options);
return Array.isArray(options)
? options.map(_options => handleFunction(_options, argv))
: handleFunction(options, argv);
};
function handleExport(options) {
const isES6DefaultExported =
typeof options === "object" && options !== null && typeof options.default !== "undefined";
return isES6DefaultExported ? options.default : options;
}
function handleFunction(options, argv) {
if (typeof options === "function") {
options = options(argv.env, argv);
}
return options;
}