v1.18.x
barisusakli 9 years ago
parent 19c2ce0e84
commit 3336365e53

@ -1,24 +1,29 @@
"use strict";
var uglifyjs = require('uglify-js'),
less = require('less'),
async = require('async'),
fs = require('fs'),
file = require('./src/file'),
crypto = require('crypto'),
utils = require('./public/src/utils'),
var uglifyjs = require('uglify-js');
var async = require('async');
var fs = require('fs');
var file = require('./src/file');
Minifier = {
var Minifier = {
js: {}
};
};
/* Javascript */
Minifier.js.minify = function (scripts, minify, callback) {
scripts = scripts.filter(function(file) {
return file && file.endsWith('.js');
});
async.filter(scripts, file.exists, function(scripts) {
async.filter(scripts, function(script, next) {
file.exists(script, function(exists) {
if (!exists) {
console.warn('[minifier] file not found, ' + script);
}
next(exists);
});
}, function(scripts) {
if (minify) {
minifyScripts(scripts, callback);
} else {
@ -54,7 +59,7 @@ function minifyScripts(scripts, callback) {
} catch(err) {
process.send({
type: 'error',
payload: err.message
message: err.message
});
}
}
@ -64,7 +69,7 @@ function concatenateScripts(scripts, callback) {
if (err) {
process.send({
type: 'error',
payload: err
message: err.message
});
return;
}

@ -126,11 +126,11 @@ module.exports = function(Meta) {
}
break;
case 'error':
winston.error('[meta/js] Could not compile ' + target + ': ' + message.payload.message);
winston.error('[meta/js] Could not compile ' + target + ': ' + message.message);
minifier.kill();
if (typeof callback === 'function') {
callback(new Error(message.payload));
callback(new Error(message.message));
} else {
process.exit(0);
}

Loading…
Cancel
Save