diff --git a/src/core/coreref.ts b/src/core/coreref.ts new file mode 100644 index 0000000..68f9380 --- /dev/null +++ b/src/core/coreref.ts @@ -0,0 +1,20 @@ +import { ChannelManager } from '../channel'; +import { NPMExecutor } from '../npm'; +import { PluginManager, PluginMetaLoader } from '../plugin'; +import { RepositoryManager } from '../plugin/repository'; +import { Configuration, IEnvironment } from '../types'; +import { ScopedEventEmitter } from '../util'; + +export interface ISqueebotCore { + environment: IEnvironment; + npm: NPMExecutor; + stream: ScopedEventEmitter; + pluginManager: PluginManager; + repositoryManager: RepositoryManager; + channelManager: ChannelManager; + pluginLoader: PluginMetaLoader; + config: Configuration; + + initialize(autostart: boolean): Promise; + shutdown(): void; +} diff --git a/src/core/index.ts b/src/core/index.ts index 84616cc..022c175 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,2 +1,3 @@ -export { loadEnvironment } from './environment'; -export { Logger, logger } from './logger'; +export * from './environment'; +export * from './logger'; +export * from './coreref'; diff --git a/src/types/config.ts b/src/types/config.ts index 0273a9b..a2ed24f 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -36,7 +36,7 @@ export class Configuration { if (key.indexOf('.') !== -1) { const split = key.split('.'); const first = this.get(split[0], null, from); - if (first) { + if (first != null) { return this.get(split.slice(1).join('.'), defval, first); } return defval; @@ -55,7 +55,7 @@ export class Configuration { return defval; } - if (!from[key]) { + if (from[key] == null) { return defval; } @@ -71,7 +71,7 @@ export class Configuration { if (key.indexOf('.') !== -1) { const split = key.split('.'); const first = this.get(split[0], null, from); - if (first) { + if (first != null) { return this.set(split.slice(1).join('.'), value, first); } return false; @@ -90,10 +90,6 @@ export class Configuration { return false; } - if (!from[key]) { - return false; - } - from[key] = value; return true; } @@ -102,7 +98,7 @@ export class Configuration { this.defaults = defconf; } - private saveDefaults(): void { + public saveDefaults(): void { this.config = this.defaults || {}; this.save(); }