blob: e3f37364efd1ef4a6e887420a67151b4fec3715f [file]
import * as config from './config.js';
const commands = [
'isonline',
'help',
'config'
];
const nemo = {
config: null
};
Object.defineProperty(nemo, 'commands', {
get: () => {
if (nemo.config === null) {
throw new Error('run nemo.load before');
}
return commandFuncs;
}
});
const commandFuncs = {};
nemo.load = function load () {
return new Promise((resolve, reject) => {
config
.load()
.then((config) => {
nemo.config = config;
commands.forEach((cmd) => {
commandFuncs[cmd] = require('./' + cmd + '.js');
});
resolve(nemo);
}).catch((err) => {
reject(err);
});
});
};
export default nemo;