Fallback to the local npm install if there are problems resolving the npm -g root path. [closes #122]

Former-commit-id: 1cbf807877e51198853950e5ebd1b49a6e20d123
This commit is contained in:
John-David Dalton
2012-11-19 21:42:54 -08:00
parent fcceaa168f
commit 93636180df

View File

@@ -99,22 +99,28 @@
/*--------------------------------------------------------------------------*/
exec('npm -g root', function(exception, stdout) {
if (!exception) {
try {
var isGlobal = path.resolve(basePath, '..') == fs.realpathSync(stdout.trim());
} catch(e) {
exception = e;
}
}
if (exception) {
console.error([
'There was a problem loading the npm registry. 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:',
'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 + '.'
'Please submit an issue on the GitHub issue tracker: ' + process.env.npm_package_bugs_url
].join('\n'));
console.error(exception);
process.exit();
}
// exit early if not a global install
if (path.resolve(basePath, '..') != fs.realpathSync(stdout.trim())) {
if (!isGlobal) {
return;
}
// download the Closure Compiler