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

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

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

    https://github.com/apache/cordova-lib/pull/398#discussion_r54079611
  
    --- Diff: cordova-lib/src/plugman/platforms/common.js ---
    @@ -22,7 +22,39 @@ var shell = require('shelljs'),
         fs    = require('fs'),
         common;
     
    +var cordovaUtil = require('../../cordova/util');
    +var CordovaError = require('cordova-common').CordovaError;
    +var xmlHelpers = require('cordova-common').xmlHelpers;
    +
     module.exports = common = {
    +    package_name: function(project_dir) {
    +
    +        var configPaths = [
    +            // preferred location if cordova >= 3.4
    +            path.join(project_dir, 'config.xml'),
    +            // older location
    +            path.join(project_dir, 'www/config.xml'),
    +        ];
    +
    +        var cordovaRoot = cordovaUtil.isCordova();
    +        if (cordovaRoot) {
    +            // CB-10662 If we're in cli project then add project's config 
as a fallback
    +            configPaths.push(path.join(cordovaRoot, 'config.xml'));
    +        }
    +
    +        for (var i = 0; i < configPaths.length; i++) {
    +            var configPath = configPaths[i];
    +            // If no config there try next path
    +            if (!fs.existsSync(configPath)) continue;
    +
    +            var widget_doc = xmlHelpers.parseElementtreeSync(configPath);
    +            return widget_doc._root.attrib.id;
    +        }
    +
    +        // No configs found - fail with meaningful error message
    +        throw new CordovaError('Unable to find project\'s config in none 
of ' +
    +            'the following directories:\n\t' + configPaths.join('\n\t'));
    --- End diff --
    
    I would suggest "any" instead of "none".


> Adding browser platform fails if plugins added since fix for CB-10641
> ---------------------------------------------------------------------
>
>                 Key: CB-10662
>                 URL: https://issues.apache.org/jira/browse/CB-10662
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: CordovaLib
>            Reporter: Tim Barham
>            Assignee: Vladimir Kotikov
>            Priority: Blocker
>              Labels: browser, regression, triaged
>
> Since the fix for [CB-10641|https://issues.apache.org/jira/browse/CB-10641], 
> adding the browser platform throws an exception if a plugin has been added to 
> the project:
> {noformat}
> $ cordova create AddBrowserError
> Creating a new cordova project.
> $ cd AddBrowserError
> $ cordova plugin add cordova-plugin-device
> Fetching plugin "cordova-plugin-device@~1.1.1" via npm
> $ cordova platform add browser
> Adding browser project...
> Running command: cmd "/s /c "cordova-browser\4.0.0\package\bin\create.bat 
> AddBrowserError\platforms\browser io.cordova.hellocordova HelloCordova""
> Creating Browser project. Path: platforms\browser
> Installing "cordova-plugin-device" for browser
> Failed to install 'cordova-plugin-device':Error: ENOENT: no such file or 
> directory, open 'AddBrowserError\platforms\browser\config.xml'
>     at Error (native)
>     at Object.fs.openSync (fs.js:549:18)
>     at Object.fs.readFileSync (fs.js:397:15)
>     at Object.module.exports.parseElementtreeSync 
> (cordova-common\src\util\xml-helpers.js:118:27)
>     at Object.module.exports.package_name 
> (cordova-lib\src\plugman\platforms\browser.js:51:38)
>     at cordova-lib\src\platforms\PlatformApiPoly.js:264:67
>     at _fulfilled (cordova-common\node_modules\q\q.js:834:54)
>     at self.promiseDispatch.done (cordova-common\node_modules\q\q.js:863:30)
>     at Promise.promise.promiseDispatch 
> (cordova-common\node_modules\q\q.js:796:13)
>     at cordova-common\node_modules\q\q.js:857:14
> {noformat}



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

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

Reply via email to