src/configurationReader.js
/**
 * Reads and parses a confugration file.
 *
 * @returns {Promise<Object|Error>} A promise that holds the parsed configuration object or an error object.
 * @param {string} configPath The path to the configuration file that should be read and parsed.
 * @param {Object=} parentConfig An optional configuration object that represents the parent configuration of the
 *        current configuration file. This is used for inehritung configuration settings.
 * @param {VariableManager=} variableManager An object that is used for variable resolution.
 */
Reads and parses a confugration file.
@returns {Promise} A promise that holds the parsed configuration object or an error object.
@param {string} configPath The path to the configuration file that should be read and parsed.
@param {Object=} parentConfig An optional configuration object that represents the parent configuration of the
current configuration file. This is used for inehritung configuration settings.
@param {VariableManager=} variableManager An object that is used for variable resolution.
Reads and parses a confugration file . @returns { Promise } A promise that holds the parsed configuration object or an error object . @param { string } configPath The path to the configuration file that should be read and parsed . @param { Object = } parentConfig An optional configuration object that represents the parent configuration of the current configuration file . This is used for inehritung configuration settings . @param { VariableManager = } variableManager An object that is used for variable resolution .
function readAndParseConfiguration (configPath, parentConfig, variableManager) {
    var deferred = Q.defer();
    fs.readFile(configPath, 'utf8', (err, data) => {
        if (err) {
            deferred.reject(err);
        } else {
            try {
                var configObject =  (JSON.parse( (data)));
                var configNormalizer =
                        new ConfigurationNormalizer(configObject, path.dirname(configPath), variableManager);
                var normalizedConfig = configNormalizer.normalize();
                deferred.resolve(mergeConfigurations(normalizedConfig, path.resolve(configPath), parentConfig));
            } catch (configError) {
                deferred.reject(new Error('Could not read the configuration file "' + configPath + '"!\n' +
                                          configError));
            }
        }
    });
    return deferred.promise;
}
function readAndParseConfiguration ( configPath , parentConfig , variableManager ) { var deferred = Q . defer ( ) ; fs . readFile ( configPath , 'utf8' , ( err , data ) => { if ( err ) { deferred . reject ( err ) ; } else { try { var configObject = ( JSON . parse ( ( data ) ) ) ; var configNormalizer = new ConfigurationNormalizer ( configObject , path . dirname ( configPath ) , variableManager ) ; var normalizedConfig = configNormalizer . normalize ( ) ; deferred . resolve ( mergeConfigurations ( normalizedConfig , path . resolve ( configPath ) , parentConfig ) ) ; } catch ( configError ) { deferred . reject ( new Error ( 'Could not read the configuration file "' + configPath + '"!\n' + configError ) ) ; } } } ) ; return deferred . promise ; }
Reads and parses a confugration file.
Reads and parses a confugration file .
/** @type {Object} */ /** @type {string} */