mirror of
https://github.com/ONLYOFFICE/server.git
synced 2026-04-07 14:04:35 +08:00
[bug] Fix after merge
This commit is contained in:
@ -135,7 +135,7 @@ Context.prototype.toJSON = function() {
|
||||
};
|
||||
Context.prototype.getCfg = function(property, defaultValue) {
|
||||
if (this.config){
|
||||
return getImpl(this.config, property) ?? defaultValue;
|
||||
return utils.getImpl(this.config, property) ?? defaultValue;
|
||||
}
|
||||
return defaultValue;
|
||||
};
|
||||
@ -147,30 +147,5 @@ Context.prototype.getFullCfg = function() {
|
||||
return utils.deepMergeObjects(config.util.toObject(), this.config);
|
||||
};
|
||||
|
||||
/**
|
||||
* Underlying get mechanism
|
||||
*
|
||||
* @private
|
||||
* @method getImpl
|
||||
* @param object {object} - Object to get the property for
|
||||
* @param property {string | array[string]} - The property name to get (as an array or '.' delimited string)
|
||||
* @return value {*} - Property value, including undefined if not defined.
|
||||
*/
|
||||
function getImpl(object, property) {
|
||||
//from https://github.com/node-config/node-config/blob/a8b91ac86b499d11b90974a2c9915ce31266044a/lib/config.js#L137
|
||||
var t = this,
|
||||
elems = Array.isArray(property) ? property : property.split('.'),
|
||||
name = elems[0],
|
||||
value = object[name];
|
||||
if (elems.length <= 1) {
|
||||
return value;
|
||||
}
|
||||
// Note that typeof null === 'object'
|
||||
if (value === null || typeof value !== 'object') {
|
||||
return undefined;
|
||||
}
|
||||
return getImpl(value, elems.slice(1));
|
||||
};
|
||||
|
||||
exports.Context = Context;
|
||||
exports.global = new Context();
|
||||
|
||||
@ -1444,4 +1444,30 @@ exports.watchWithFallback = async function watchWithFallback(ctx, dirPath, fileP
|
||||
ctx.logger.info(`watchWithFallback error ${dirPath} fallback to watchFile ${filePath}: ${err.message}`);
|
||||
return fs.watchFile(filePath, opts, listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Underlying get mechanism
|
||||
*
|
||||
* @private
|
||||
* @method getImpl
|
||||
* @param object {object} - Object to get the property for
|
||||
* @param property {string | array[string]} - The property name to get (as an array or '.' delimited string)
|
||||
* @return value {*} - Property value, including undefined if not defined.
|
||||
*/
|
||||
function getImpl(object, property) {
|
||||
//from https://github.com/node-config/node-config/blob/a8b91ac86b499d11b90974a2c9915ce31266044a/lib/config.js#L137
|
||||
var t = this,
|
||||
elems = Array.isArray(property) ? property : property.split('.'),
|
||||
name = elems[0],
|
||||
value = object[name];
|
||||
if (elems.length <= 1) {
|
||||
return value;
|
||||
}
|
||||
// Note that typeof null === 'object'
|
||||
if (value === null || typeof value !== 'object') {
|
||||
return undefined;
|
||||
}
|
||||
return getImpl(value, elems.slice(1));
|
||||
};
|
||||
|
||||
exports.getImpl = getImpl;
|
||||
Reference in New Issue
Block a user