Add core reference interface
This commit is contained in:
parent
d3c649f684
commit
53fc842210
20
src/core/coreref.ts
Normal file
20
src/core/coreref.ts
Normal file
@ -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<void>;
|
||||||
|
shutdown(): void;
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
export { loadEnvironment } from './environment';
|
export * from './environment';
|
||||||
export { Logger, logger } from './logger';
|
export * from './logger';
|
||||||
|
export * from './coreref';
|
||||||
|
@ -36,7 +36,7 @@ export class Configuration {
|
|||||||
if (key.indexOf('.') !== -1) {
|
if (key.indexOf('.') !== -1) {
|
||||||
const split = key.split('.');
|
const split = key.split('.');
|
||||||
const first = this.get(split[0], null, from);
|
const first = this.get(split[0], null, from);
|
||||||
if (first) {
|
if (first != null) {
|
||||||
return this.get(split.slice(1).join('.'), defval, first);
|
return this.get(split.slice(1).join('.'), defval, first);
|
||||||
}
|
}
|
||||||
return defval;
|
return defval;
|
||||||
@ -55,7 +55,7 @@ export class Configuration {
|
|||||||
return defval;
|
return defval;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from[key]) {
|
if (from[key] == null) {
|
||||||
return defval;
|
return defval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ export class Configuration {
|
|||||||
if (key.indexOf('.') !== -1) {
|
if (key.indexOf('.') !== -1) {
|
||||||
const split = key.split('.');
|
const split = key.split('.');
|
||||||
const first = this.get(split[0], null, from);
|
const first = this.get(split[0], null, from);
|
||||||
if (first) {
|
if (first != null) {
|
||||||
return this.set(split.slice(1).join('.'), value, first);
|
return this.set(split.slice(1).join('.'), value, first);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -90,10 +90,6 @@ export class Configuration {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!from[key]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
from[key] = value;
|
from[key] = value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -102,7 +98,7 @@ export class Configuration {
|
|||||||
this.defaults = defconf;
|
this.defaults = defconf;
|
||||||
}
|
}
|
||||||
|
|
||||||
private saveDefaults(): void {
|
public saveDefaults(): void {
|
||||||
this.config = this.defaults || {};
|
this.config = this.defaults || {};
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user