This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
2020-11-01 22:46:04 +00:00

25 lines
614 B
JavaScript

"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;
}