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.

prepareOptions.js 614B

123456789101112131415161718192021222324
  1. "use strict";
  2. module.exports = function prepareOptions(options, argv) {
  3. argv = argv || {};
  4. options = handleExport(options);
  5. return Array.isArray(options)
  6. ? options.map(_options => handleFunction(_options, argv))
  7. : handleFunction(options, argv);
  8. };
  9. function handleExport(options) {
  10. const isES6DefaultExported =
  11. typeof options === "object" && options !== null && typeof options.default !== "undefined";
  12. return isES6DefaultExported ? options.default : options;
  13. }
  14. function handleFunction(options, argv) {
  15. if (typeof options === "function") {
  16. options = options(argv.env, argv);
  17. }
  18. return options;
  19. }