Split options to another file
This commit is contained in:
12
bin/getOptions.js
Normal file
12
bin/getOptions.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
module.exports = function getOptions(argv) {
|
||||||
|
return {
|
||||||
|
host: argv.hostname || process.env.npm_package_remotedev_hostname || null,
|
||||||
|
port: Number(argv.port || process.env.npm_package_remotedev_port) || 8000,
|
||||||
|
protocol: argv.protocol || process.env.npm_package_remotedev_protocol || 'http',
|
||||||
|
protocolOptions: !(argv.protocol === 'https') ? null : {
|
||||||
|
key: argv.key || process.env.npm_package_remotedev_key || null,
|
||||||
|
cert: argv.cert || process.env.npm_package_remotedev_cert || null,
|
||||||
|
passphrase: argv.passphrase || process.env.npm_package_remotedev_passphrase || null
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -1,16 +1,11 @@
|
|||||||
|
var assign = require('object-assign');
|
||||||
|
var getOptions = require('./getOptions');
|
||||||
|
|
||||||
module.exports = function(argv) {
|
module.exports = function(argv) {
|
||||||
var SocketCluster = require('socketcluster').SocketCluster;
|
var SocketCluster = require('socketcluster').SocketCluster;
|
||||||
|
var options = assign(getOptions(argv), {
|
||||||
return new SocketCluster({
|
|
||||||
host: argv.hostname || process.env.npm_package_remotedev_hostname || null,
|
|
||||||
port: Number(argv.port || process.env.npm_package_remotedev_port) || 8000,
|
|
||||||
workerController: __dirname + '/worker.js',
|
workerController: __dirname + '/worker.js',
|
||||||
allowClientPublish: false,
|
allowClientPublish: false
|
||||||
protocol: argv.protocol || process.env.npm_package_remotedev_protocol || 'http',
|
|
||||||
protocolOptions: !(argv.protocol === 'https') ? null : {
|
|
||||||
key: argv.key || process.env.npm_package_remotedev_key || null,
|
|
||||||
cert: argv.cert || process.env.npm_package_remotedev_cert || null,
|
|
||||||
passphrase: argv.passphrase || process.env.npm_package_remotedev_passphrase || null
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
return new SocketCluster(options);
|
||||||
};
|
};
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
"ejs": "^2.4.1",
|
"ejs": "^2.4.1",
|
||||||
"express": "^4.13.3",
|
"express": "^4.13.3",
|
||||||
"minimist": "^1.2.0",
|
"minimist": "^1.2.0",
|
||||||
|
"object-assign": "^4.1.0",
|
||||||
"socketcluster": "^4.3.1"
|
"socketcluster": "^4.3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user