You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2015/12/01 02:13:10 UTC

[jira] [Commented] (CB-9590) install header-files breaks with new naming convention on ubuntu

    [ https://issues.apache.org/jira/browse/CB-9590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15032843#comment-15032843 ] 

ASF GitHub Bot commented on CB-9590:
------------------------------------

Github user TimBarham commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/294#discussion_r46228904
  
    --- 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 --
    
    This will fail with a JavaScript error if `plugin_id` does not start with `cordova-plugin`, since `match()` will return `null`. Instead, should do the `match()` call separately, then only try to get the first array element if the return value is not `null`. If the return value *is* `null`, then should use some fallback (like camel-case the entire `plugin_id`, for example).


> install header-files breaks with new naming convention on ubuntu
> ----------------------------------------------------------------
>
>                 Key: CB-9590
>                 URL: https://issues.apache.org/jira/browse/CB-9590
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaLib
>            Reporter: David Barth
>
> Trying to install a plugin using the new naming convention breaks on the current ubuntu version.
> cordova plugin add cordova-plugin-console
> Fetching plugin "cordova-plugin-console" via npm
> npm http GET https://registry.npmjs.org/cordova-plugin-console
> npm http 304 https://registry.npmjs.org/cordova-plugin-console
> Installing "cordova-plugin-console" for ubuntu
> Error during processing of action! Attempting to revert...
> Failed to install 'cordova-plugin-console':TypeError: Uh oh!
> Cannot read property '0' of null
>     at Object.module.exports.header-file.install (/usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/platforms/ubuntu.js:74:57)
>     at installWrapper (/usr/share/cordova-cli/node_modules/cordova-lib/src/platforms/platforms.js:76:32)
>     at Object.ActionStack.process (/usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/util/action-stack.js:68:25)
>     at handleInstall (/usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/install.js:543:20)
>     at /usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/install.js:335:28
>     at _fulfilled (/usr/share/cordova-cli/node_modules/q/q.js:787:54)
>     at self.promiseDispatch.done (/usr/share/cordova-cli/node_modules/q/q.js:816:30)
>     at Promise.promise.promiseDispatch (/usr/share/cordova-cli/node_modules/q/q.js:749:13)
>     at /usr/share/cordova-cli/node_modules/q/q.js:509:49
>     at flush (/usr/share/cordova-cli/node_modules/q/q.js:108:17)
> TypeError: Uh oh!
> Cannot read property '0' of null
>     at Object.module.exports.header-file.install (/usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/platforms/ubuntu.js:74:57)
>     at installWrapper (/usr/share/cordova-cli/node_modules/cordova-lib/src/platforms/platforms.js:76:32)
>     at Object.ActionStack.process (/usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/util/action-stack.js:68:25)
>     at handleInstall (/usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/install.js:543:20)
>     at /usr/share/cordova-cli/node_modules/cordova-lib/src/plugman/install.js:335:28
>     at _fulfilled (/usr/share/cordova-cli/node_modules/q/q.js:787:54)
>     at self.promiseDispatch.done (/usr/share/cordova-cli/node_modules/q/q.js:816:30)
>     at Promise.promise.promiseDispatch (/usr/share/cordova-cli/node_modules/q/q.js:749:13)
>     at /usr/share/cordova-cli/node_modules/q/q.js:509:49
>     at flush (/usr/share/cordova-cli/node_modules/q/q.js:108:17)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org