Repository: cordova-ios
Updated Branches:
  refs/heads/master 4ca3f28ba -> b8ea31fe8


CB-10138  Adds missing plugin metadata to plugin_list module

This closes #194


Project: http://git-wip-us.apache.org/repos/asf/cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-ios/commit/b8ea31fe
Tree: http://git-wip-us.apache.org/repos/asf/cordova-ios/tree/b8ea31fe
Diff: http://git-wip-us.apache.org/repos/asf/cordova-ios/diff/b8ea31fe

Branch: refs/heads/master
Commit: b8ea31fe8edf9503a0a13d82a31182821c44c0ca
Parents: 4ca3f28
Author: Ian Maffett <[email protected]>
Authored: Wed Feb 17 08:02:40 2016 -0500
Committer: Vladimir Kotikov <[email protected]>
Committed: Wed Feb 17 17:09:48 2016 +0300

----------------------------------------------------------------------
 .../scripts/cordova/lib/plugman/Plugman.js          | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/b8ea31fe/bin/templates/scripts/cordova/lib/plugman/Plugman.js
----------------------------------------------------------------------
diff --git a/bin/templates/scripts/cordova/lib/plugman/Plugman.js 
b/bin/templates/scripts/cordova/lib/plugman/Plugman.js
index e4c7981..8c7b115 100644
--- a/bin/templates/scripts/cordova/lib/plugman/Plugman.js
+++ b/bin/templates/scripts/cordova/lib/plugman/Plugman.js
@@ -183,6 +183,10 @@ Plugman.prototype._addModulesInfo = function(plugin, 
targetDir) {
     });
 
     this._platformJson.root.modules = 
installedModules.concat(modulesToInstall);
+    if (!this._platformJson.root.plugin_metadata) {
+        this._platformJson.root.plugin_metadata = {};
+    }
+    this._platformJson.root.plugin_metadata[plugin.id] = plugin.version;
     this._writePluginModules(targetDir);
     this._platformJson.save();
 };
@@ -196,20 +200,13 @@ Plugman.prototype._addModulesInfo = function(plugin, 
targetDir) {
  *   directories.
  */
 Plugman.prototype._writePluginModules = function (targetDir) {
-    var self = this;
     // Write out moduleObjects as JSON wrapped in a cordova module to 
cordova_plugins.js
     var final_contents = 'cordova.define(\'cordova/plugin_list\', 
function(require, exports, module) {\n';
     final_contents += 'module.exports = ' + 
JSON.stringify(this._platformJson.root.modules, null, '    ') + ';\n';
     final_contents += 'module.exports.metadata = \n';
     final_contents += '// TOP OF METADATA\n';
 
-    var pluginMetadata = Object.keys(this._platformJson.root.installed_plugins)
-    .reduce(function (metadata, plugin) {
-        metadata[plugin] = 
self._platformJson.root.installed_plugins[plugin].version;
-        return metadata;
-    }, {});
-
-    final_contents += JSON.stringify(pluginMetadata, null, 4) + '\n';
+    final_contents += JSON.stringify(this._platformJson.root.plugin_metadata, 
null, 4) + '\n';
     final_contents += '// BOTTOM OF METADATA\n';
     final_contents += '});'; // Close cordova.define.
 
@@ -239,6 +236,9 @@ Plugman.prototype._removeModulesInfo = function(plugin, 
targetDir) {
     });
 
     this._platformJson.root.modules = updatedModules;
+    if (this._platformJson.root.plugin_metadata) {
+        delete this._platformJson.root.plugin_metadata[plugin.id];
+    }
     this._writePluginModules(targetDir);
     this._platformJson.save();
 };


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to