From 95aa5c9f1c45b79151dc9650447faeaf12a75d96 Mon Sep 17 00:00:00 2001 From: Andrew Grieve Date: Fri, 15 Aug 2014 13:58:53 -0400 Subject: [PATCH] CB-7321 Don't require ant for create script --- bin/lib/check_reqs.js | 4 ++-- bin/templates/cordova/lib/build.js | 6 +++++- bin/templates/cordova/lib/clean.js | 6 +++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/lib/check_reqs.js b/bin/lib/check_reqs.js index 17a3bd4f..db454749 100644 --- a/bin/lib/check_reqs.js +++ b/bin/lib/check_reqs.js @@ -55,7 +55,7 @@ module.exports.get_target = function() { } } -// Returns a promise. +// Returns a promise. Called only by build and clean commands. module.exports.check_ant = function() { return tryCommand('ant -version', 'Failed to run "ant -version", make sure you have ant installed and added to your PATH.'); } @@ -123,6 +123,6 @@ module.exports.check_android = function() { // Returns a promise. module.exports.run = function() { - return Q.all([this.check_ant(), this.check_java(), this.check_android()]); + return Q.all([this.check_java(), this.check_android()]); } diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index 6336ecf5..5134f412 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -25,6 +25,7 @@ var shell = require('shelljs'), path = require('path'), fs = require('fs'), ROOT = path.join(__dirname, '..', '..'); +var check_reqs = require('./check_reqs'); function hasCustomRules() { @@ -60,9 +61,12 @@ module.exports.run = function(build_type) { return Q.reject('Build option \'' + build_type + '\' not recognized.'); } // Without our custom_rules.xml, we need to clean before building. - var ret = Q(); + var ret; if (!hasCustomRules()) { + // clean will call check_ant() for us. ret = require('./clean').run(); + } else { + ret = check_reqs.check_ant(); } return ret.then(function() { return spawn('ant', args); diff --git a/bin/templates/cordova/lib/clean.js b/bin/templates/cordova/lib/clean.js index 0a2e0ce0..f2158290 100644 --- a/bin/templates/cordova/lib/clean.js +++ b/bin/templates/cordova/lib/clean.js @@ -22,6 +22,7 @@ var build = require('./build'), spawn = require('./spawn'), path = require('path'); +var check_reqs = require('./check_reqs'); /* * Cleans the project using ant @@ -29,7 +30,10 @@ var build = require('./build'), */ module.exports.run = function() { var args = build.getAntArgs('clean'); - return spawn('ant', args); + return check_reqs.check_ant() + .then(function() { + return spawn('ant', args); + }); } module.exports.help = function() {