mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 18:37:50 +00:00
Simplify build/post-install.js.
Former-commit-id: a3f657f9721b18cef3c43b36a64e83b77d63eeea
This commit is contained in:
@@ -3,8 +3,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/** Load Node modules */
|
/** Load Node modules */
|
||||||
var execFile = require('child_process').execFile,
|
var fs = require('fs'),
|
||||||
fs = require('fs'),
|
|
||||||
https = require('https'),
|
https = require('https'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
tar = require('../vendor/tar/tar.js'),
|
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 you’re installing the',
|
|
||||||
'Lo-Dash command-line executable (via `npm install -g lodash`), you’ll 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);
|
.on('error', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*--------------------------------------------------------------------------*/
|
||||||
* The `child_process.execFile` callback.
|
|
||||||
*
|
if (process.env.npm_config_global === 'true') {
|
||||||
* @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;
|
|
||||||
}
|
|
||||||
// download the Closure Compiler
|
// download the Closure Compiler
|
||||||
getDependency({
|
getDependency({
|
||||||
'title': 'the Closure Compiler',
|
'title': 'the Closure Compiler',
|
||||||
@@ -152,13 +116,4 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
try {
|
|
||||||
execFile('npm', [ '-g', 'root' ], onExecFile);
|
|
||||||
} catch(e) {
|
|
||||||
console.error(oopsMessage);
|
|
||||||
console.error(e);
|
|
||||||
}
|
|
||||||
}());
|
}());
|
||||||
|
|||||||
Reference in New Issue
Block a user