processOptions.js 783 B

1234567891011121314151617181920212223242526272829
  1. 'use strict';
  2. const createConfig = require('./createConfig');
  3. const defaultPort = require('./defaultPort');
  4. function processOptions(config, argv, callback) {
  5. // processOptions {Promise}
  6. if (typeof config.then === 'function') {
  7. config
  8. .then((conf) => processOptions(conf, argv, callback))
  9. .catch((err) => {
  10. // eslint-disable-next-line no-console
  11. console.error(err.stack || err);
  12. // eslint-disable-next-line no-process-exit
  13. process.exit(1);
  14. });
  15. return;
  16. }
  17. // Taken out of yargs because we must know if
  18. // it wasn't given by the user, in which case
  19. // we should use portfinder.
  20. const options = createConfig(config, argv, { port: defaultPort });
  21. callback(config, options);
  22. }
  23. module.exports = processOptions;