Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E49D4186D9 for ; Thu, 25 Feb 2016 11:04:20 +0000 (UTC) Received: (qmail 55455 invoked by uid 500); 25 Feb 2016 11:04:20 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 55422 invoked by uid 500); 25 Feb 2016 11:04:20 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 55403 invoked by uid 99); 25 Feb 2016 11:04:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Feb 2016 11:04:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 106C5E3A67; Thu, 25 Feb 2016 11:04:20 +0000 (UTC) From: TimBarham To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-lib pull request: CB-10662 Use project's config.xml as a f... Content-Type: text/plain Message-Id: <20160225110420.106C5E3A67@git1-us-west.apache.org> Date: Thu, 25 Feb 2016 11:04:20 +0000 (UTC) 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