in src/plugman/variable-merge.js [34:62]
function mergeVariables (plugin_dir, platform, options) {
options.pluginInfoProvider = options.pluginInfoProvider || new PluginInfoProvider();
const pluginInfo = options.pluginInfoProvider.get(plugin_dir);
const prefs = pluginInfo.getPreferences(platform);
const keys = Object.keys(prefs);
options.cli_variables = options.cli_variables || {};
// For all vars defined in prefs, take the value from cli_variables or
// default to the value from prefs if truthy.
const mergedVars = {};
for (const key of keys) {
if (key in options.cli_variables) {
mergedVars[key] = options.cli_variables[key];
} else if (prefs[key]) {
mergedVars[key] = options.cli_variables[key] = prefs[key];
}
}
// Test for missing vars after having applied defaults
const mergedVarKeys = new Set(Object.keys(mergedVars));
const missing_vars = keys.filter(key => !mergedVarKeys.has(key));
if (missing_vars.length > 0) {
throw new Error('Variable(s) missing: ' + missing_vars.join(', '));
}
return mergedVars;
}