You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by TimBarham <gi...@git.apache.org> on 2016/02/25 12:04:20 UTC

[GitHub] cordova-lib pull request: CB-10662 Use project's config.xml as a f...

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".


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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