Fix oputil
This commit is contained in:
parent
9d8b43b605
commit
c91ae50c6b
|
@ -12,7 +12,12 @@ exports.Config = class Config extends ConfigLoader {
|
|||
super(options);
|
||||
}
|
||||
|
||||
static create(baseConfigPath, cb) {
|
||||
static create(baseConfigPath, options, cb) {
|
||||
if (!cb && _.isFunction(options)) {
|
||||
cb = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
const replacePaths = [
|
||||
'loginServers.ssh.algorithms.kex',
|
||||
'loginServers.ssh.algorithms.cipher',
|
||||
|
@ -24,7 +29,7 @@ exports.Config = class Config extends ConfigLoader {
|
|||
'args', 'sendArgs', 'recvArgs', 'recvArgsNonBatch',
|
||||
];
|
||||
|
||||
const options = {
|
||||
const configOptions = Object.assign({}, options, {
|
||||
defaultConfig : DefaultConfig,
|
||||
defaultsCustomizer : (defaultVal, configVal, key, path) => {
|
||||
if (Array.isArray(defaultVal) && Array.isArray(configVal)) {
|
||||
|
@ -43,9 +48,9 @@ exports.Config = class Config extends ConfigLoader {
|
|||
Events.emit(Events.getSystemEvents().ConfigChanged);
|
||||
}
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
systemConfigInstance = new Config(options);
|
||||
systemConfigInstance = new Config(configOptions);
|
||||
systemConfigInstance.init(baseConfigPath, err => {
|
||||
if (err) {
|
||||
console.stdout(`Configuration ${baseConfigPath} error: ${err.message}`); // eslint-disable-line no-console
|
||||
|
|
|
@ -13,12 +13,14 @@ module.exports = class ConfigLoader {
|
|||
defaultConfig = {},
|
||||
defaultsCustomizer = null,
|
||||
onReload = null,
|
||||
keepWsc = false,
|
||||
} =
|
||||
{
|
||||
hotReload : true,
|
||||
defaultConfig : {},
|
||||
defaultsCustomizer : null,
|
||||
onReload : null,
|
||||
keepWsc : false,
|
||||
}
|
||||
)
|
||||
{
|
||||
|
@ -28,6 +30,7 @@ module.exports = class ConfigLoader {
|
|||
this.defaultConfig = defaultConfig;
|
||||
this.defaultsCustomizer = defaultsCustomizer;
|
||||
this.onReload = onReload;
|
||||
this.keepWsc = keepWsc;
|
||||
}
|
||||
|
||||
init(baseConfigPath, cb) {
|
||||
|
@ -176,6 +179,7 @@ module.exports = class ConfigLoader {
|
|||
const options = {
|
||||
filePath,
|
||||
hotReload : this.hotReload,
|
||||
keepWsc : this.keepWsc,
|
||||
callback : this._configFileChanged.bind(this),
|
||||
};
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ function getConfigPath() {
|
|||
function initConfig(cb) {
|
||||
const configPath = getConfigPath();
|
||||
|
||||
config.init(configPath, { keepWsc : true, hotReload : false }, cb);
|
||||
config.Config.create(configPath, { keepWsc : true, hotReload : false }, cb);
|
||||
}
|
||||
|
||||
function initConfigAndDatabases(cb) {
|
||||
|
|
Loading…
Reference in New Issue