mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature(cloudcmd) add plugins
This commit is contained in:
parent
39934033b8
commit
4d14071ede
8 changed files with 186 additions and 7 deletions
|
|
@ -14,7 +14,9 @@ const {assign} = Object;
|
|||
const pathConfig = os.homedir() + '/.cloudcmd.json';
|
||||
const currentConfig = readjson.sync.try(pathConfig);
|
||||
|
||||
module.exports = (config, fn = config) => {
|
||||
module.exports = (_config, _plugins, _fn) => {
|
||||
const {config, plugins, fn} = parse(_config, _plugins, _fn);
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
const after = () => {
|
||||
|
|
@ -28,6 +30,7 @@ module.exports = (config, fn = config) => {
|
|||
|
||||
app.use(cloudcmd({
|
||||
socket,
|
||||
plugins,
|
||||
config: assign(defaultConfig(), config)
|
||||
}));
|
||||
|
||||
|
|
@ -43,3 +46,25 @@ 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