cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject [17/32] git commit: CB-5801 exec->spawn in build to make sure compile errors are shown.
Date Mon, 03 Feb 2014 20:26:18 GMT
CB-5801 exec->spawn in build to make sure compile errors are shown.


Project: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/commit/7f77d2bb
Tree: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/tree/7f77d2bb
Diff: http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/diff/7f77d2bb

Branch: refs/heads/3.4.x
Commit: 7f77d2bbd46c88109c217d7f84366bb8d62248f3
Parents: 166d26a
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Wed Jan 15 11:41:03 2014 -0500
Committer: Archana Naik <naika@lab126.com>
Committed: Mon Feb 3 11:09:46 2014 -0800

----------------------------------------------------------------------
 bin/templates/cordova/lib/build.js | 21 +++++++---------
 bin/templates/cordova/lib/clean.js |  6 ++---
 bin/templates/cordova/lib/spawn.js | 43 +++++++++++++++++++++++++++++++++
 3 files changed, 55 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/7f77d2bb/bin/templates/cordova/lib/build.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js
index f0adb37..7ea7d09 100644
--- a/bin/templates/cordova/lib/build.js
+++ b/bin/templates/cordova/lib/build.js
@@ -20,9 +20,9 @@
 */
 
 var shell   = require('shelljs'),
-    exec    = require('./exec'),
-    Q       = require('q'),
     clean   = require('./clean'),
+    spawn   = require('./spawn'),
+    Q       = require('q'),
     path    = require('path'),
     fs      = require('fs'),
     ROOT    = path.join(__dirname, '..', '..');
@@ -34,13 +34,13 @@ var shell   = require('shelljs'),
 module.exports.run = function(build_type) {
     //default build type
     build_type = typeof build_type !== 'undefined' ? build_type : "--debug";
-    var cmd;
+    var args;
     switch(build_type) {
         case '--debug' :
-            cmd = 'ant debug -f ' + path.join(ROOT, 'build.xml');
+            args = ['debug', '-f', path.join(ROOT, 'build.xml')];
             break;
         case '--release' :
-            cmd = 'ant release -f ' + path.join(ROOT, 'build.xml');
+            args = ['release', '-f', path.join(ROOT, 'build.xml')];
             break;
         case '--nobuild' :
             console.log('Skipping build...');
@@ -48,13 +48,10 @@ module.exports.run = function(build_type) {
         default :
             return Q.reject('Build option \'' + build_type + '\' not recognized.');
     }
-    if(cmd) {
-        return clean.run() // TODO: Can we stop cleaning every time and let ant build incrementally?
-        .then(function() {
-            return exec(cmd);
-        });
-    }
-    return Q();
+    return clean.run() // TODO: Can we stop cleaning every time and let ant build incrementally?
+    .then(function() {
+        return spawn('ant', args);
+    });
 }
 
 /*

http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/7f77d2bb/bin/templates/cordova/lib/clean.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/clean.js b/bin/templates/cordova/lib/clean.js
index 0f955f6..14c9b15 100644
--- a/bin/templates/cordova/lib/clean.js
+++ b/bin/templates/cordova/lib/clean.js
@@ -19,16 +19,16 @@
        under the License.
 */
 
-var exec  = require('./exec'),
+var spawn = require('./spawn'),
     path  = require('path'),
-    ROOT = path.join(__dirname, '..', '..');
+    ROOT  = path.join(__dirname, '..', '..');
 
 /*
  * Cleans the project using ant
  * Returns a promise.
  */
 module.exports.run = function() {
-    return exec('ant clean -f ' + path.join(ROOT, 'build.xml'));
+    return spawn('ant', ['clean', '-f', path.join(ROOT, 'build.xml')]);
 }
 
 module.exports.help = function() {

http://git-wip-us.apache.org/repos/asf/cordova-amazon-fireos/blob/7f77d2bb/bin/templates/cordova/lib/spawn.js
----------------------------------------------------------------------
diff --git a/bin/templates/cordova/lib/spawn.js b/bin/templates/cordova/lib/spawn.js
new file mode 100644
index 0000000..cea7a06
--- /dev/null
+++ b/bin/templates/cordova/lib/spawn.js
@@ -0,0 +1,43 @@
+#!/usr/bin/env node
+
+/*
+       Licensed to the Apache Software Foundation (ASF) under one
+       or more contributor license agreements.  See the NOTICE file
+       distributed with this work for additional information
+       regarding copyright ownership.  The ASF licenses this file
+       to you under the Apache License, Version 2.0 (the
+       "License"); you may not use this file except in compliance
+       with the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+       Unless required by applicable law or agreed to in writing,
+       software distributed under the License is distributed on an
+       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+       KIND, either express or implied.  See the License for the
+       specific language governing permissions and limitations
+       under the License.
+*/
+
+var child_process = require('child_process'),
+    Q       = require('q');
+
+// Takes a command and optional current working directory.
+module.exports = function(cmd, args, opt_cwd) {
+    var d = Q.defer();
+    try {
+        var child = child_process.spawn(cmd, args, {cwd: opt_cwd, stdio: 'inherit'});
+        child.on('exit', function(code) {
+            if (code) {
+                d.reject('Error code ' + code + ' for command: ' + cmd + ' with args: ' +
args);
+            } else {
+                d.resolve();
+            }
+        });
+    } catch(e) {
+        console.error('error caught: ' + e);
+        d.reject(e);
+    }
+    return d.promise;
+}
+


Mime
View raw message