Simplify build/post-install.js.

Former-commit-id: a3f657f9721b18cef3c43b36a64e83b77d63eeea
This commit is contained in:
John-David Dalton
2012-12-21 18:07:05 -06:00
parent 1b347fc185
commit 3908fa5c57

View File

@@ -3,8 +3,7 @@
'use strict';
/** Load Node modules */
var execFile = require('child_process').execFile,
fs = require('fs'),
var fs = require('fs'),
https = require('https'),
path = require('path'),
tar = require('../vendor/tar/tar.js'),
@@ -39,21 +38,6 @@
};
}());
/** The message to display when the install mode is undetectable */
var oopsMessage = [
'Oops! There was a problem detecting the install mode. If youre installing the',
'Lo-Dash command-line executable (via `npm install -g lodash`), youll need to',
'manually install UglifyJS and the Closure Compiler by running:',
'',
"curl -H 'Accept: " + mediaType + "' " + location.href + '/' + closureId + " | tar xvz -C '" + vendorPath + "'",
"curl -H 'Accept: " + mediaType + "' " + location.href + '/' + uglifyId + " | tar xvz -C '" + vendorPath + "'",
'',
'Please submit an issue on the GitHub issue tracker: ' + process.env.npm_package_bugs_url
].join('\n');
/** Reassign `existsSync` for older versions of Node */
fs.existsSync || (fs.existsSync = path.existsSync);
/*--------------------------------------------------------------------------*/
/**
@@ -111,29 +95,9 @@
.on('error', callback);
}
/**
* The `child_process.execFile` callback.
*
* @private
* @param {Object|Undefined} exception The error object.
* @param {String} stdout The stdout buffer.
*/
function onExecFile(exception, stdout) {
if (!exception) {
try {
var root = stdout.trim(),
isGlobal = fs.existsSync(root) && path.resolve(basePath, '..') == fs.realpathSync(root);
} catch(e) {
exception = e;
}
}
if (exception) {
console.error(oopsMessage);
console.error(exception);
}
if (!isGlobal) {
return;
}
/*--------------------------------------------------------------------------*/
if (process.env.npm_config_global === 'true') {
// download the Closure Compiler
getDependency({
'title': 'the Closure Compiler',
@@ -152,13 +116,4 @@
}
});
}
/*--------------------------------------------------------------------------*/
try {
execFile('npm', [ '-g', 'root' ], onExecFile);
} catch(e) {
console.error(oopsMessage);
console.error(e);
}
}());