You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2016/08/09 09:31:31 UTC
[2/6] cordova-lib git commit: CB-11205 Respect saved variables when
installing plugin
CB-11205 Respect saved variables when installing plugin
This closes #471
Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/b5dc35ba
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/b5dc35ba
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/b5dc35ba
Branch: refs/heads/6.3.x
Commit: b5dc35bac1ac0391237c04bcb76a34fe82607d64
Parents: 6342022
Author: Nikita Matrosov <ni...@rp.ru>
Authored: Fri Jul 29 14:47:44 2016 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Mon Aug 8 10:45:28 2016 +0300
----------------------------------------------------------------------
cordova-lib/spec-cordova/save.spec.js | 27 +++++++++++++++++++++++++++
cordova-lib/src/cordova/plugin.js | 6 ++++++
2 files changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b5dc35ba/cordova-lib/spec-cordova/save.spec.js
----------------------------------------------------------------------
diff --git a/cordova-lib/spec-cordova/save.spec.js b/cordova-lib/spec-cordova/save.spec.js
index e2be5a5..b5ece83 100644
--- a/cordova-lib/spec-cordova/save.spec.js
+++ b/cordova-lib/spec-cordova/save.spec.js
@@ -412,6 +412,33 @@ describe('(save flag)', function () {
});
}, TIMEOUT);
+ it('spec.14.1 should restore plugin with variables', function (done) {
+ platform('add', platformLocalPathNewer)
+ .then(function () {
+ return cordova.raw.plugin('add', variablePluginUrl, {
+ 'save': true,
+ 'cli_variables': {
+ 'APP_ID':'123456789',
+ 'APP_NAME':'myApplication'
+ }
+ });
+ }).then(function () {
+ expect(helpers.getPluginVariable(appPath, variablePluginName, 'APP_ID')).toBe('123456789');
+ expect(helpers.getPluginVariable(appPath, variablePluginName, 'APP_NAME')).toBe('myApplication');
+ return cordova.raw.plugin('rm', variablePluginName);
+ }).then(function() {
+ expect(path.join(appPath, 'plugins', variablePluginName)).not.toExist();
+ return cordova.raw.plugin('add', variablePluginName);
+ }).then(function() {
+ expect(path.join(appPath, 'plugins', variablePluginName)).toExist();
+ done();
+ }).catch(function (err) {
+ console.log(err.message);
+ expect(true).toBe(false);
+ done();
+ });
+ }, TIMEOUT);
+
it('spec.15 save git url as spec', function (done) {
platform('add', platformLocalPathNewer)
.then(function () {
http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/b5dc35ba/cordova-lib/src/cordova/plugin.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/plugin.js b/cordova-lib/src/cordova/plugin.js
index e8d6acb..d803425 100644
--- a/cordova-lib/src/cordova/plugin.js
+++ b/cordova-lib/src/cordova/plugin.js
@@ -155,6 +155,12 @@ module.exports = function plugin(command, targets, opts) {
.then(function(pluginInfo) {
// Validate top-level required variables
var pluginVariables = pluginInfo.getPreferences();
+ opts.cli_variables = opts.cli_variables || {};
+ var pluginEntry = cfg.getPlugin(pluginInfo.id);
+ var pluginEntryVariables = pluginEntry ? pluginEntry.variables : {};
+ Object.keys(pluginVariables).forEach(function(varName) {
+ opts.cli_variables[varName] = opts.cli_variables[varName] || pluginEntryVariables[varName];
+ });
var missingVariables = Object.keys(pluginVariables)
.filter(function (variableName) {
// discard variables with default value
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org