mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
test(before) config, plugin -> options
This commit is contained in:
parent
4d14071ede
commit
ba93a87eed
5 changed files with 38 additions and 50 deletions
|
|
@ -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
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue