test(before) config, plugin -> options

This commit is contained in:
coderaiser 2016-11-29 15:41:31 +02:00
parent 4d14071ede
commit ba93a87eed
5 changed files with 38 additions and 50 deletions

View file

@ -14,8 +14,12 @@ const {assign} = Object;
const pathConfig = os.homedir() + '/.cloudcmd.json';
const currentConfig = readjson.sync.try(pathConfig);
module.exports = (_config, _plugins, _fn) => {
const {config, plugins, fn} = parse(_config, _plugins, _fn);
module.exports = (options, fn = options) => {
if (fn === options) {
options = {};
}
const {config, plugins} = options;
const app = express();
const server = http.createServer(app);
@ -46,25 +50,3 @@ function defaultConfig() {
};
}
function parse(config, plugins, fn) {
if (typeof plugins === 'undefined')
return {
fn: config,
config: undefined,
plugins: undefined
}
if (typeof fn === 'undefined')
return {
config,
fn: plugins,
plugins: undefined
}
return {
config,
plugins,
fn
};
}