Github user stevengill commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/590#discussion_r135664112
  
    --- Diff: src/cordova/plugin/util.js ---
    @@ -35,3 +40,39 @@ function saveToConfigXmlOn (config_json, options) {
         var autosave = config_json.auto_save_plugins || false;
         return autosave || options.save;
     }
    +
    +/*
    + * Merges cli and config.xml variables.
    + *
    + * @param   {object}    pluginInfo
    + * @param   {object}    config.xml
    + * @param   {object}    options
    + *
    + * @return  {object}    object containing the new merged variables
    + */
    +
    +function mergeVariables (pluginInfo, cfg, opts) {
    +    // Validate top-level required variables
    +    var pluginVariables = pluginInfo.getPreferences();
    +    opts.cli_variables = opts.cli_variables || {};
    +    var pluginEntry = cfg.getPlugin(pluginInfo.id);
    +    // Get variables from config.xml
    +    var configVariables = pluginEntry ? pluginEntry.variables : {};
    +    // Add config variable if it's missing in cli_variables
    +    Object.keys(configVariables).forEach(function (variable) {
    +        opts.cli_variables[variable] = opts.cli_variables[variable] || 
configVariables[variable];
    +    });
    +    var missingVariables = Object.keys(pluginVariables)
    +        .filter(function (variableName) {
    +            // discard variables with default value
    +            return !(pluginVariables[variableName] || 
opts.cli_variables[variableName]);
    +        });
    +
    +    if (missingVariables.length) {
    +        events.emit('verbose', 'Removing ' + pluginInfo.dir + ' because 
mandatory plugin variables were missing.');
    +        shell.rm('-rf', pluginInfo.dir);
    +        var msg = 'Variable(s) missing (use: --variable ' + 
missingVariables.join('=value --variable ') + '=value).';
    +        return Q.reject(new CordovaError(msg));
    --- End diff --
    
    Change this to `throw new CordovaError(msg)`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to