You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by an...@apache.org on 2012/07/27 02:29:15 UTC

[22/78] [abbrv] git commit: build and emulate working.

build and emulate working.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/commit/96b85119
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/tree/96b85119
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/diff/96b85119

Branch: refs/heads/cordova-client
Commit: 96b8511986f35df46646c8a53c073d26e7afc013
Parents: 37ddd02
Author: Fil Maj <ma...@gmail.com>
Authored: Tue Jul 17 14:44:44 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Tue Jul 17 14:44:44 2012 -0700

----------------------------------------------------------------------
 README.md      |    1 +
 cordova.js     |   11 +----------
 src/build.js   |   26 ++++++++------------------
 src/emulate.js |   30 ++++++++++++++++++++++++++++++
 4 files changed, 40 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/96b85119/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index f43a146..9ba5c9d 100644
--- a/README.md
+++ b/README.md
@@ -112,3 +112,4 @@ launch for.
 - clean up build + emulate commands
 - add plugin integration via pluginstall
 - `grep` through this project for 'TODO'
+- moar tests

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/96b85119/cordova.js
----------------------------------------------------------------------
diff --git a/cordova.js b/cordova.js
index bd68252..72cf813 100755
--- a/cordova.js
+++ b/cordova.js
@@ -81,14 +81,5 @@ module.exports = {
     },
     platform:require('./src/platform'),
     build:require('./src/build'),
-    emulate: function emulate() {
-        var cmd = util.format("%s/cordova/emulate", process.cwd());
-        exec(cmd, function(err, stderr, stdout) {
-            if (err) 
-                console.error('An error occurred attempting to start emulator.', err);
-            
-            console.log(stdout);
-            console.log(stderr);
-        });
-   }
+    emulate:require('./src/emulate')
 };

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/96b85119/src/build.js
----------------------------------------------------------------------
diff --git a/src/build.js b/src/build.js
index 40a3cc2..be380ac 100644
--- a/src/build.js
+++ b/src/build.js
@@ -1,5 +1,6 @@
 var cordova_util = require('./util'),
     path = require('path'),
+    exec = require('child_process').exec,
     config_parser = require('./config_parser'),
     fs = require('fs'),
     util = require('util');
@@ -16,23 +17,12 @@ module.exports = function build () {
     var cfg = new config_parser(xml);
     var platforms = cfg.ls_platforms();
 
-    // Check if we have projects setup for each platform already.
+    // Iterate over each added platform and shell out to debug command
     platforms.map(function(platform) {
-        var dir = path.join(projectRoot, 'platforms', platform);
-        try {
-            fs.lstatSync(dir);
-        } catch(e) {
-            // Does not exist.
-        }
-
-    });
-
-    var cmd = util.format("%s/cordova/debug", process.cwd());
-    exec(cmd, function(err, stderr, stdout) {
-        if (err) 
-            console.error('An error occurred while building project.', err)
-        
-        console.log(stdout)
-        console.log(stderr)
+        var cmd = path.join(projectRoot, 'platforms', platform, 'cordova', 'debug');
+        exec(cmd, function(err, stderr, stdout) {
+            if (err) 
+                console.error('An error occurred while building the ' + platform + ' project.', err);
+        });
     });
-}
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-labs/blob/96b85119/src/emulate.js
----------------------------------------------------------------------
diff --git a/src/emulate.js b/src/emulate.js
new file mode 100644
index 0000000..02dfe49
--- /dev/null
+++ b/src/emulate.js
@@ -0,0 +1,30 @@
+var cordova_util = require('./util'),
+    path = require('path'),
+    exec = require('child_process').exec,
+    config_parser = require('./config_parser'),
+    fs = require('fs'),
+    util = require('util');
+
+module.exports = function emulate () {
+    var projectRoot = cordova_util.isCordova(process.cwd());
+
+    if (!projectRoot) {
+        console.error('Current working directory is not a Cordova-based project.');
+        return;
+    }
+
+    var xml = path.join(projectRoot, 'www', 'config.xml');
+    var cfg = new config_parser(xml);
+    var platforms = cfg.ls_platforms();
+
+    // Iterate over each added platform and shell out to debug command
+    platforms.map(function(platform) {
+        var cmd = path.join(projectRoot, 'platforms', platform, 'cordova', 'emulate');
+        exec(cmd, function(err, stderr, stdout) {
+            if (err) 
+                console.error('An error occurred while emulating/deploying the ' + platform + ' project.', err);
+            console.log(stdout);
+        });
+    });
+};
+