src/config.js
function resolve(value, conf, ring = []) {
	value.match(CONFIG_VAR_REGEX).forEach((variable) => {
		const key = variable.substring(variable.lastIndexOf('${') + 2, variable.lastIndexOf('}'));

		if (ring.includes(key)) {
			throw `Circular dependency error: cannot resolve variable(s) ${ring}.`;
		}
		ring.push(key);

		let resolved = conf[key];
		if (!resolved) {
			throw `Could not resolve ${key} - make sure this key is defined in _config.yml.`;
		}
		if (CONFIG_VAR_REGEX.test(resolved)) {
			resolved = resolve(resolved, conf, ring);
		}
		value = value.replace(variable, resolved);
		ring.pop();
	});
	return value;
}
function resolve(value, conf, ring = []) {
	value.match(CONFIG_VAR_REGEX).forEach((variable) => {
		const key = variable.substring(variable.lastIndexOf('${') + 2, variable.lastIndexOf('}'));

		if (ring.includes(key)) {
			throw `Circular dependency error: cannot resolve variable(s) ${ring}.`;
		}
		ring.push(key);

		let resolved = conf[key];
		if (!resolved) {
			throw `Could not resolve ${key} - make sure this key is defined in _config.yml.`;
		}
		if (CONFIG_VAR_REGEX.test(resolved)) {
			resolved = resolve(resolved, conf, ring);
		}
		value = value.replace(variable, resolved);
		ring.pop();
	});
	return value;
}
function resolve ( value , conf , ring = [ ] ) { value . match ( CONFIG_VAR_REGEX ) . forEach ( ( variable ) => { const key = variable . substring ( variable . lastIndexOf ( '${' ) + 2 , variable . lastIndexOf ( '}' ) ) ; if ( ring . includes ( key ) ) { throw ` ${ ring } ` ; } ring . push ( key ) ; let resolved = conf [ key ] ; if ( ! resolved ) { throw ` ${ key } ` ; } if ( CONFIG_VAR_REGEX . test ( resolved ) ) { resolved = resolve ( resolved , conf , ring ) ; } value = value . replace ( variable , resolved ) ; ring . pop ( ) ; } ) ; return value ; }
Recursively resolve variable depedencies.
@param {String} value - String to resolve of dependencies.
@param {Dictionary} conf - The parsed config file.
@param {Array} ring - An array of previously seen keys.
Recursively resolve variable depedencies .