Repository: cordova-windows
Updated Branches:
  refs/heads/master 1410f3c3d -> 45e5bd131


CB-10138 Adds missing plugin metadata to plugin_list module for Windows


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

Branch: refs/heads/master
Commit: 45e5bd131d1f38e781b328499fd900896d403e82
Parents: 1410f3c
Author: Ryan Fiorini (Intel) <[email protected]>
Authored: Wed Feb 17 10:11:55 2016 -0500
Committer: Ryan Fiorini (Intel) <[email protected]>
Committed: Wed Feb 17 10:11:55 2016 -0500

----------------------------------------------------------------------
 template/cordova/Api.js | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/45e5bd13/template/cordova/Api.js
----------------------------------------------------------------------
diff --git a/template/cordova/Api.js b/template/cordova/Api.js
index 5803817..d4a9e6c 100644
--- a/template/cordova/Api.js
+++ b/template/cordova/Api.js
@@ -409,6 +409,11 @@ Api.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();
 };
@@ -435,6 +440,10 @@ Api.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();
 };
@@ -448,20 +457,13 @@ Api.prototype._removeModulesInfo = function(plugin, 
targetDir) {
  *   directories.
  */
 Api.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, '    ') + '\n';
+    final_contents += JSON.stringify(this._platformJson.root.plugin_metadata, 
null, 4) + ';\n';
     final_contents += '// BOTTOM OF METADATA\n';
     final_contents += '});'; // Close cordova.define.
 


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

Reply via email to