mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature: client: DIRCLIENT -> DIR_CLIENT
This commit is contained in:
parent
ce49d9d6ad
commit
656000e7e0
2 changed files with 113 additions and 113 deletions
|
|
@ -16,45 +16,45 @@ const noJS = (a) => a.replace(/.js$/, '');
|
|||
module.exports = function loadModule(params) {
|
||||
if (!params)
|
||||
return;
|
||||
|
||||
|
||||
const {path} = params;
|
||||
|
||||
|
||||
const name = path && noJS(pascalCase(path));
|
||||
const doBefore = params.dobefore;
|
||||
|
||||
|
||||
if (CloudCmd[name])
|
||||
return;
|
||||
|
||||
|
||||
CloudCmd[name] = () => {
|
||||
exec(doBefore);
|
||||
|
||||
|
||||
const {prefix} = CloudCmd;
|
||||
const pathFull = prefix + CloudCmd.DIRCLIENT_MODULES + path + '.js';
|
||||
|
||||
const pathFull = prefix + CloudCmd.DIR_CLIENT_MODULES + path + '.js';
|
||||
|
||||
return loadJS(pathFull).then(async () => {
|
||||
const newModule = async (f) => f && f();
|
||||
const module = CloudCmd[name];
|
||||
|
||||
|
||||
Object.assign(newModule, module);
|
||||
|
||||
|
||||
CloudCmd[name] = newModule;
|
||||
|
||||
|
||||
CloudCmd.log('init', name);
|
||||
await module.init();
|
||||
|
||||
|
||||
return newModule;
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
CloudCmd[name].show = async (...args) => {
|
||||
CloudCmd.log('show', name, args);
|
||||
const m = CloudCmd[name];
|
||||
|
||||
|
||||
const [e, a] = await tryToCatch(m);
|
||||
|
||||
|
||||
if (e)
|
||||
return console.error(e);
|
||||
|
||||
|
||||
return await a.show(...args);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue