Github user david-barth-canonical commented on a diff in the pull request:
https://github.com/apache/cordova-lib/pull/294#discussion_r46471716
--- Diff: cordova-lib/src/plugman/platforms/ubuntu.js ---
@@ -29,6 +29,51 @@ function toCamelCase(str) {
}).join('');
}
+function getPluginXml(plugin_dir) {
+ var et = require('elementtree'),
+ fs = require('fs'),
+ path = require('path');
+
+ var pluginxml;
+ var config_path = path.join(plugin_dir, 'plugin.xml');
+
+ if (fs.existsSync(config_path)) {
+ // Get the current plugin.xml file
+ pluginxml = et.parse(fs.readFileSync(config_path, 'utf-8'));
+ }
+
+ return pluginxml;
+}
+
+function findClassName(pluginxml, plugin_id) {
+ var class_name;
+
+ // first check if we have a class-name parameter in the plugin config
+ if (pluginxml) {
+ var platform = pluginxml.find("./platform/[@name='ubuntu']/");
+ if (platform) {
+ var param =
platform.find("./config-file/[@target='config.xml']/feature/param/[@name='ubuntu-package']");
+ if (param && param.attrib) {
+ class_name = param.attrib.value;
+ return class_name;
+ }
+ }
+ }
+
+ // fallback to guess work, based on the plugin package name
+
+ if (plugin_id.match(/\.[^.]+$/)) {
+ // old-style plugin name
+ class_name = plugin_id.match(/\.[^.]+$/)[0].substr(1);
+ class_name = toCamelCase(class_name);
+ } else {
+ class_name =
plugin_id.match(/cordova\-plugin\-([\w\-]+)$/)[0].substr(15);
--- End diff --
Thanks! I updated the branch to take that into account. I was forcing
plugins to upgrade to adding their class name to the XML file, but there is a
more gradual way ;)
If that PR can't be re-opened I opened
https://github.com/apache/cordova-lib/pull/349 . Otherwise feel free to close
this other one.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]