mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-22 00:32:55 +08:00
CB-10138 Adds missing plugin metadata to plugin_list module. This closes #254
This commit is contained in:
parent
7669378c6e
commit
e08d0671ab
18
bin/templates/cordova/Api.js
vendored
18
bin/templates/cordova/Api.js
vendored
@ -431,6 +431,11 @@ Api.prototype._addModulesInfo = function(plugin, targetDir) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._platformJson.root.modules = installedModules.concat(modulesToInstall);
|
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._writePluginModules(targetDir);
|
||||||
this._platformJson.save();
|
this._platformJson.save();
|
||||||
};
|
};
|
||||||
@ -457,6 +462,10 @@ Api.prototype._removeModulesInfo = function(plugin, targetDir) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this._platformJson.root.modules = updatedModules;
|
this._platformJson.root.modules = updatedModules;
|
||||||
|
if (this._platformJson.root.plugin_metadata) {
|
||||||
|
delete this._platformJson.root.plugin_metadata[plugin.id];
|
||||||
|
}
|
||||||
|
|
||||||
this._writePluginModules(targetDir);
|
this._writePluginModules(targetDir);
|
||||||
this._platformJson.save();
|
this._platformJson.save();
|
||||||
};
|
};
|
||||||
@ -470,20 +479,13 @@ Api.prototype._removeModulesInfo = function(plugin, targetDir) {
|
|||||||
* directories.
|
* directories.
|
||||||
*/
|
*/
|
||||||
Api.prototype._writePluginModules = function (targetDir) {
|
Api.prototype._writePluginModules = function (targetDir) {
|
||||||
var self = this;
|
|
||||||
// Write out moduleObjects as JSON wrapped in a cordova module to cordova_plugins.js
|
// 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';
|
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 = ' + JSON.stringify(this._platformJson.root.modules, null, ' ') + ';\n';
|
||||||
final_contents += 'module.exports.metadata = \n';
|
final_contents += 'module.exports.metadata = \n';
|
||||||
final_contents += '// TOP OF METADATA\n';
|
final_contents += '// TOP OF METADATA\n';
|
||||||
|
|
||||||
var pluginMetadata = Object.keys(this._platformJson.root.installed_plugins)
|
final_contents += JSON.stringify(this._platformJson.root.plugin_metadata, null, 4) + ';\n';
|
||||||
.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 += '// BOTTOM OF METADATA\n';
|
final_contents += '// BOTTOM OF METADATA\n';
|
||||||
final_contents += '});'; // Close cordova.define.
|
final_contents += '});'; // Close cordova.define.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user