1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- 'use strict';
- const createConfig = require('./createConfig');
- const defaultPort = require('./defaultPort');
- const findPort = require('./findPort');
- function processOptions(config, argv, callback) {
-
- if (typeof config.then === 'function') {
- config
- .then((conf) => processOptions(conf, argv, callback))
- .catch((err) => {
-
- console.error(err.stack || err);
-
- process.exit(1);
- });
- return;
- }
-
-
-
- const options = createConfig(config, argv, { port: defaultPort });
- if (options.socket) {
- callback(config, options);
- } else {
- findPort(options.port)
- .then((port) => {
- options.port = port;
- callback(config, options);
- })
- .catch((err) => {
-
- console.error(err.stack || err);
-
- process.exit(1);
- });
- }
- }
- module.exports = processOptions;
|