You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by br...@apache.org on 2013/05/09 16:07:18 UTC

git commit: Access config.xml from serve. Serve from platform dir only

Updated Branches:
  refs/heads/future 2a5407e8b -> 6ad6a2652


Access config.xml from serve. Serve from platform dir only


Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/6ad6a265
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/6ad6a265
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/6ad6a265

Branch: refs/heads/future
Commit: 6ad6a2652f88cbbfc3f40b5ed6d7883be8e87e61
Parents: 2a5407e
Author: Shravan Narayan <sh...@google.com>
Authored: Wed May 8 14:50:21 2013 -0400
Committer: Shravan Narayan <sh...@google.com>
Committed: Wed May 8 18:17:55 2013 -0400

----------------------------------------------------------------------
 src/metadata/android_parser.js    |    4 ++++
 src/metadata/blackberry_parser.js |    4 ++++
 src/metadata/ios_parser.js        |    7 ++++++-
 src/serve.js                      |   12 +++++++++---
 4 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6ad6a265/src/metadata/android_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/android_parser.js b/src/metadata/android_parser.js
index be3015c..79c1f2b 100644
--- a/src/metadata/android_parser.js
+++ b/src/metadata/android_parser.js
@@ -130,6 +130,10 @@ module.exports.prototype = {
         return path.join(this.path, '.staging', 'www');
     },
 
+    config_xml:function(){
+        return this.android_config;
+    },
+
     update_www:function() {
         var projectRoot = util.isCordova(this.path);
         var www = util.projectWww(projectRoot);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6ad6a265/src/metadata/blackberry_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/blackberry_parser.js b/src/metadata/blackberry_parser.js
index 16fcbad..97cdd59 100644
--- a/src/metadata/blackberry_parser.js
+++ b/src/metadata/blackberry_parser.js
@@ -94,6 +94,10 @@ module.exports.prototype = {
         return path.join(this.path, '.staging', 'www');
     },
 
+    config_xml:function(){
+        return this.config_path;
+    },
+
     update_www:function() {
         var projectRoot = util.isCordova(this.path);
         var www = util.projectWww(projectRoot);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6ad6a265/src/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/src/metadata/ios_parser.js b/src/metadata/ios_parser.js
index 5e83ed3..5c22256 100644
--- a/src/metadata/ios_parser.js
+++ b/src/metadata/ios_parser.js
@@ -55,7 +55,8 @@ module.exports = function ios_parser(project) {
     }
     this.path = project;
     this.pbxproj = path.join(this.xcodeproj, 'project.pbxproj');
-    this.config = new config_parser(path.join(this.cordovaproj, 'config.xml'));
+    this.config_path = path.join(this.cordovaproj, 'config.xml');
+    this.config = new config_parser(this.config_path);
 };
 
 module.exports.check_requirements = function(callback) {
@@ -141,6 +142,10 @@ module.exports.prototype = {
         return path.join(this.path, '.staging', 'www');
     },
 
+    config_xml:function(){
+        return this.config_path;
+    },
+
     update_www:function() {
         var projectRoot = util.isCordova(this.path);
         var www = util.projectWww(projectRoot);

http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/6ad6a265/src/serve.js
----------------------------------------------------------------------
diff --git a/src/serve.js b/src/serve.js
index 771f64f..2829847 100644
--- a/src/serve.js
+++ b/src/serve.js
@@ -30,11 +30,11 @@ var cordova_util = require('./util'),
     url = require("url");
 
 
-function launch_server(www, platform_www, port) {
+function launch_server(www, platform_www, config_xml_path, port) {
     port = port || 8000;
 
     // Searches these directories in order looking for the requested file.
-    var searchPath = [www, platform_www];
+    var searchPath = [platform_www];
 
     var server = http.createServer(function(request, response) {
         var uri = url.parse(request.url).pathname;
@@ -48,6 +48,9 @@ function launch_server(www, platform_www, port) {
             }
 
             var filename = path.join(searchPath[pathIndex], uri);
+            if(uri === "/config.xml"){
+                filename = config_xml_path;
+            }
 
             fs.exists(filename, function(exists) {
                 if(!exists) {
@@ -82,7 +85,7 @@ module.exports = function serve (platform, port) {
     var returnValue = {};
 
     module.exports.config(platform, port, function (config) {
-        returnValue.server = launch_server(config.paths[0], config.paths[1], port);
+        returnValue.server = launch_server(config.paths[0], config.paths[1], config.config_xml_path, port);
     });
 
     // Hack for testing despite its async nature.
@@ -113,6 +116,8 @@ module.exports.config = function (platform, port, callback) {
 
     var result = {
         paths: [],
+        // Config file path
+        config_xml_path : "",
         // Default port is 8000 if not given. This is also the default of the Python module.
         port: port || 8000
     };
@@ -137,6 +142,7 @@ module.exports.config = function (platform, port, callback) {
     // Update the related platform project from the config
     parser.update_project(cfg, function() {
         result.paths.push(parser.www_dir());
+        result.config_xml_path = parser.config_xml();
         callback(result);
     });
 }