diff --git a/lib/exe.js b/lib/exe.js index ab8c2c4..e527030 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -28,6 +28,7 @@ var async = require("async"), request = require("request"), path = require("path"), fs = require("fs"), + colors = require('colors'), ncp = require("ncp").ncp, ProgressBar = require("progress"), child_process = require("child_process"), @@ -244,7 +245,7 @@ exports.compile = function (options, complete) { "This indicates a failure in the build process. " + "There is likely additional information above." ); - throw new Error("The release executable was not built ('" + nodeCompiler.releasePath + "')"); + process.exit(1); } else { next(); } @@ -423,12 +424,22 @@ function _getNodeCompiler (nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complet version: path.basename(nodeFileDir), releasePath: path.join(dir, "out", "Release", binary), make: function (next) { - var cfg = "./configure", configure; - if(isPy !== "python") { - configure = spawn(isPy, [cfg].concat(nodeConfigureArgs), { cwd: dir }); - } else { - configure = spawn(cfg, nodeConfigureArgs, { cwd: dir }); - } + var cfg = "./configure", + configure; + + var conf = [cfg]; + + console.log(isPy); + console.log(dir); + + if(isPy !== "python") { + conf = [conf].concat(nodeConfigureArgs); + } + + // should work for all use cases now. + configure = spawn(isPy, conf, { + cwd: dir.toString('ascii') + }); // local function, move to top eventually function _loop(dir) { @@ -463,6 +474,29 @@ function _getNodeCompiler (nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complet configure.stdout.pipe(process.stdout); configure.stderr.pipe(process.stderr); + + // on error + configure.on("error", function(err) { + console.log('Error:', err); + console.log(''); + console.log('Details:'); + console.log('command =', isPy, cfg, conf_args || ''); + console.log('cwd =', dir); + + var configure_path = path.join(dir, 'configure'); + var contains_configure = fs.existsSync(configure_path); + + console.log('cwd contains configure,', (contains_configure ? colors.green('yes') : colors.red('no'))); + + var configure_size = fs.statSync(configure_path).size; + + console.log('configure is non-zero size,', ((configure_size > 0 ) ? colors.green('yes') : colors.red('no'))); + + _log("error", "failed to launch configure."); + process.exit(1); + }); + + // when it's finished configure.on("close", function () { if(isPy !== "python") { /** @@ -475,13 +509,24 @@ function _getNodeCompiler (nodeFileDir, nodeConfigureArgs, nodeMakeArgs, complet // loop over depends _loop(dir); } + + if(nodeMakeArgs === undefined) { + nodeMakeArgs = []; + } + var platformMake = "make"; if (os.platform().match(/bsd$/) != null) { platformMake = "gmake"; } + var make = spawn(platformMake, nodeMakeArgs, { cwd: dir }); make.stdout.pipe(process.stdout); make.stderr.pipe(process.stderr); + make.on("error", function(err) { + console.log(err); + _log("error", "failed to run make."); + process.exit(1); + }) make.on("close", function () { next(); }); diff --git a/lib/log.js b/lib/log.js index b46d393..d06a2e0 100644 --- a/lib/log.js +++ b/lib/log.js @@ -22,6 +22,8 @@ * **/ +var colors = require('colors'); + /** * standard output, takes 3 different types. * log, error, and warn @@ -31,8 +33,6 @@ **/ function _log () { - var colors = require('colors'); - var args = Array.prototype.slice.call(arguments, 0), level = args.shift();