mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Cleanup build/post-install.js.
Former-commit-id: e92e1c1e1c1cd821721085a3e1520756c158dfb5
This commit is contained in:
@@ -122,7 +122,6 @@
|
|||||||
return value.replace(/^(--compilation_level)=.+$/, '$1=SIMPLE_OPTIMIZATIONS');
|
return value.replace(/^(--compilation_level)=.+$/, '$1=SIMPLE_OPTIMIZATIONS');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// the standard error stream, standard output stream, and Closure Compiler process
|
// the standard error stream, standard output stream, and Closure Compiler process
|
||||||
var error = '',
|
var error = '',
|
||||||
output = '',
|
output = '',
|
||||||
@@ -133,14 +132,12 @@
|
|||||||
callback = message;
|
callback = message;
|
||||||
message = null;
|
message = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isSilent) {
|
if (!this.isSilent) {
|
||||||
console.log(message == null
|
console.log(message == null
|
||||||
? 'Compressing ' + path.basename(this.outputPath, '.js') + ' using the Closure Compiler...'
|
? 'Compressing ' + path.basename(this.outputPath, '.js') + ' using the Closure Compiler...'
|
||||||
: message
|
: message
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
compiler.stdout.on('data', function(data) {
|
compiler.stdout.on('data', function(data) {
|
||||||
// append the data to the output stream
|
// append the data to the output stream
|
||||||
output += data;
|
output += data;
|
||||||
@@ -186,14 +183,12 @@
|
|||||||
callback = message;
|
callback = message;
|
||||||
message = null;
|
message = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isSilent) {
|
if (!this.isSilent) {
|
||||||
console.log(message == null
|
console.log(message == null
|
||||||
? 'Compressing ' + path.basename(this.outputPath, '.js') + ' using UglifyJS...'
|
? 'Compressing ' + path.basename(this.outputPath, '.js') + ' using UglifyJS...'
|
||||||
: message
|
: message
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = ugly.gen_code(
|
result = ugly.gen_code(
|
||||||
// enable unsafe transformations
|
// enable unsafe transformations
|
||||||
@@ -246,7 +241,6 @@
|
|||||||
if (!this.isSilent) {
|
if (!this.isSilent) {
|
||||||
console.log('Done. Size: %d bytes.', result.length);
|
console.log('Done. Size: %d bytes.', result.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
// store the gzipped result and report the size
|
// store the gzipped result and report the size
|
||||||
this.compiled.gzip = result;
|
this.compiled.gzip = result;
|
||||||
|
|
||||||
|
|||||||
@@ -16,19 +16,45 @@
|
|||||||
/** The path of the `vendor` directory */
|
/** The path of the `vendor` directory */
|
||||||
var vendorPath = path.join(basePath, 'vendor');
|
var vendorPath = path.join(basePath, 'vendor');
|
||||||
|
|
||||||
|
/** The Git object ID of `closure-compiler.tar.gz` */
|
||||||
|
var closureId = 'aa29a2ecf6f51d4da5a2a418c0d4ea0e368ee80d';
|
||||||
|
|
||||||
|
/** The Git object ID of `uglifyjs.tar.gz` */
|
||||||
|
var uglifyId = '827f406a02626c1c6723e8ae281b6785d36375c1';
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches a required `.tar.gz` dependency with the given Git object ID from
|
* Fetches a required `.tar.gz` dependency with the given Git object ID from
|
||||||
* the Lo-Dash repo on GitHub. The object ID may be obtained by running
|
* the Lo-Dash repo on GitHub. The object ID may be obtained by running
|
||||||
* `git hash-object path/to/dependency.tar.gz`.
|
* `git hash-object path/to/dependency.tar.gz`.
|
||||||
*
|
*
|
||||||
* @param {String} objectId The Git object ID of the `.tar.gz` package.
|
* @private
|
||||||
* @param {String} The extraction target directory.
|
* @param {Object} options The options object.
|
||||||
* @param {Function} callback The function to call once the extraction finishes.
|
*
|
||||||
|
* id - The Git object ID of the `.tar.gz` file.
|
||||||
|
* onComplete - The function to call once the extraction finishes.
|
||||||
|
* path - The path of the extraction directory.
|
||||||
|
* title - The dependency's title used in status updates logged to the console.
|
||||||
*/
|
*/
|
||||||
function getDependency(objectId, targets, callback) {
|
function getDependency(options) {
|
||||||
|
options || (options = {});
|
||||||
|
|
||||||
|
var onComplete = options.onComplete,
|
||||||
|
title = options.title;
|
||||||
|
|
||||||
|
function callback(exception) {
|
||||||
|
if (exception) {
|
||||||
|
console.error('There was a problem downloading ' + title + '.');
|
||||||
|
}
|
||||||
|
onComplete(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('Downloading ' + title + '...');
|
||||||
|
|
||||||
https.get({
|
https.get({
|
||||||
'host': 'api.github.com',
|
'host': 'api.github.com',
|
||||||
'path': '/repos/bestiejs/lodash/git/blobs/' + objectId,
|
'path': '/repos/bestiejs/lodash/git/blobs/' + options.id,
|
||||||
'headers': {
|
'headers': {
|
||||||
// By default, all GitHub blob API endpoints return a JSON document
|
// By default, all GitHub blob API endpoints return a JSON document
|
||||||
// containing Base64-encoded blob data. Overriding the `Accept` header
|
// containing Base64-encoded blob data. Overriding the `Accept` header
|
||||||
@@ -37,7 +63,7 @@
|
|||||||
}
|
}
|
||||||
}, function(response) {
|
}, function(response) {
|
||||||
var parser = new tar.Extract({
|
var parser = new tar.Extract({
|
||||||
'path': targets
|
'path': options.path
|
||||||
})
|
})
|
||||||
.on('end', callback)
|
.on('end', callback)
|
||||||
.on('error', callback);
|
.on('error', callback);
|
||||||
@@ -47,6 +73,8 @@
|
|||||||
.on('error', callback);
|
.on('error', callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
exec('npm -g root', function(exception, stdout, stderr) {
|
exec('npm -g root', function(exception, stdout, stderr) {
|
||||||
if (exception || stderr) {
|
if (exception || stderr) {
|
||||||
console.error('There was a problem loading the npm registry.');
|
console.error('There was a problem loading the npm registry.');
|
||||||
@@ -56,23 +84,22 @@
|
|||||||
if (path.resolve(basePath, '..') != stdout.trim()) {
|
if (path.resolve(basePath, '..') != stdout.trim()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// download Closure Compiler
|
// download the Closure Compiler
|
||||||
console.log('Downloading Closure Compiler...');
|
getDependency({
|
||||||
getDependency('aa29a2ecf6f51d4da5a2a418c0d4ea0e368ee80d', vendorPath, function(exception) {
|
'title': 'the Closure Compiler',
|
||||||
var statusCode = 0;
|
'id': closureId,
|
||||||
if (exception) {
|
'path': vendorPath,
|
||||||
console.error('There was a problem downloading the Closure Compiler.');
|
'onComplete':function(exceptionA) {
|
||||||
statusCode = 1;
|
// download UglifyJS
|
||||||
|
getDependency({
|
||||||
|
'title': 'UglifyJS',
|
||||||
|
'id': uglifyId,
|
||||||
|
'path': vendorPath,
|
||||||
|
'onComplete': function(exceptionB) {
|
||||||
|
process.exit(exceptionA || exceptionB ? 1 : 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// download UglifyJS
|
|
||||||
console.log('Downloading UglifyJS...');
|
|
||||||
getDependency('827f406a02626c1c6723e8ae281b6785d36375c1', vendorPath, function(exception) {
|
|
||||||
if (exception) {
|
|
||||||
console.error('There was a problem downloading UglifyJS.');
|
|
||||||
statusCode = 1;
|
|
||||||
}
|
|
||||||
process.exit(statusCode);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|||||||
Reference in New Issue
Block a user