diff --git a/build/install-node.js b/build/install-node.js index e0ab6a80..12b564c3 100644 --- a/build/install-node.js +++ b/build/install-node.js @@ -86,19 +86,25 @@ } nodeDownload = function(destination, options, callback) { - return binary.download(options, destination, function(error, binaryPath) { - var output; - if (error != null) { - return callback(error); - } - output = path.join(destination, getNodeName(options)); - return fs.rename(binaryPath, output, function(error) { + var error; + try { + return binary.download(options, destination, function(error, binaryPath) { + var output; if (error != null) { return callback(error); } - return callback(null, output); + output = path.join(destination, getNodeName(options)); + return fs.rename(binaryPath, output, function(error) { + if (error != null) { + return callback(error); + } + return callback(null, output); + }); }); - }); + } catch (_error) { + error = _error; + return callback(error); + } }; async.eachLimit(bundles, 2, function(bundle, callback) { @@ -108,14 +114,15 @@ return callback(error); } console.info("Downloaded: " + (getNodeName(bundle)) + " to " + output); - return callback(null, output); + return callback(); }); }, function(error) { if (error != null) { - console.error(error); - process.exit(1); + console.error(error.message); + return console.error('Error: Couldn\'t get the required node bundle. Omitting.'); + } else { + return console.info('All NodeJS bundles downloaded'); } - return console.info('All NodeJS bundles downloaded'); }); }).call(this); diff --git a/lib/install-node.coffee b/lib/install-node.coffee index 59bbb2fb..c60373c2 100644 --- a/lib/install-node.coffee +++ b/lib/install-node.coffee @@ -56,21 +56,25 @@ for bundle in bundles console.info "- #{getNodeName(bundle)}" nodeDownload = (destination, options, callback) -> - binary.download options, destination, (error, binaryPath) -> - return callback(error) if error? - output = path.join(destination, getNodeName(options)) - fs.rename binaryPath, output, (error) -> + try + binary.download options, destination, (error, binaryPath) -> return callback(error) if error? - return callback(null, output) + output = path.join(destination, getNodeName(options)) + fs.rename binaryPath, output, (error) -> + return callback(error) if error? + return callback(null, output) + catch error + return callback(error) async.eachLimit bundles, 2, (bundle, callback) -> console.info("Downloading: #{getNodeName(bundle)} to #{DESTINATION}") return nodeDownload DESTINATION, bundle, (error, output) -> return callback(error) if error? console.info("Downloaded: #{getNodeName(bundle)} to #{output}") - return callback(null, output) + return callback() , (error) -> if error? - console.error(error) - process.exit(1) - console.info('All NodeJS bundles downloaded') + console.error(error.message) + console.error('Error: Couldn\'t get the required node bundle. Omitting.') + else + console.info('All NodeJS bundles downloaded')