From 32b5b5b1c4ea986732333c6a97b62f4b7fb0d5f1 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 22 Dec 2012 11:56:52 -0600 Subject: [PATCH] Catch module load errors in build/post-install.js. Former-commit-id: 6671d4925749d8b4d6da9ddd732bc7f436b6740d --- build/post-install.js | 60 +++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 22 deletions(-) diff --git a/build/post-install.js b/build/post-install.js index bae89fd7b..b83dd1fb9 100644 --- a/build/post-install.js +++ b/build/post-install.js @@ -4,10 +4,7 @@ /** Load Node modules */ var fs = require('fs'), - https = require('https'), - path = require('path'), - tar = require('../vendor/tar/tar.js'), - zlib = require('zlib'); + path = require('path'); /** The path of the directory that is the base of the repository */ var basePath = fs.realpathSync(path.join(__dirname, '..')); @@ -88,7 +85,7 @@ var decompressor = zlib.createUnzip(), parser = new tar.Extract({ 'path': path }); - decompressor.on('error', callback) + decompressor.on('error', callback); parser.on('end', callback).on('error', callback); response.pipe(decompressor).pipe(parser); }) @@ -98,22 +95,41 @@ /*--------------------------------------------------------------------------*/ if (process.env.npm_config_global === 'true') { - // download the Closure Compiler - getDependency({ - 'title': 'the Closure Compiler', - 'id': closureId, - 'path': vendorPath, - 'onComplete': function() { - // download UglifyJS - getDependency({ - 'title': 'UglifyJS', - 'id': uglifyId, - 'path': vendorPath, - 'onComplete': function() { - process.exit(); - } - }); - } - }); + // catch module load errors + try { + var https = require('https'), + tar = require('../vendor/tar/tar.js'), + zlib = require('zlib'); + + // download the Closure Compiler + getDependency({ + 'title': 'the Closure Compiler', + 'id': closureId, + 'path': vendorPath, + 'onComplete': function() { + // download UglifyJS + getDependency({ + 'title': 'UglifyJS', + 'id': uglifyId, + 'path': vendorPath, + 'onComplete': function() { + process.exit(); + } + }); + } + }); + } catch(e) { + console.log([ + 'Oops! There was a problem installing dependencies required by the Lo-Dash', + 'command-line executable. To manually install UglifyJS and the Closure Compiler', + 'run:', + '', + "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'", + "curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'", + '' + ].join('\n')); + + console.log(e); + } } }());