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

@ -1,24 +1,29 @@
"use strict"; "use strict";
var uglifyjs = require('uglify-js'), var uglifyjs = require('uglify-js');
less = require('less'), var async = require('async');
async = require('async'), var fs = require('fs');
fs = require('fs'), var file = require('./src/file');
file = require('./src/file'),
crypto = require('crypto'),
utils = require('./public/src/utils'),
Minifier = { var Minifier = {
js: {} js: {}
}; };
/* Javascript */ /* Javascript */
Minifier.js.minify = function (scripts, minify, callback) { Minifier.js.minify = function (scripts, minify, callback) {
scripts = scripts.filter(function(file) { scripts = scripts.filter(function(file) {
return file && file.endsWith('.js'); 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) { if (minify) {
minifyScripts(scripts, callback); minifyScripts(scripts, callback);
} else { } else {
@ -54,7 +59,7 @@ function minifyScripts(scripts, callback) {
} catch(err) { } catch(err) {
process.send({ process.send({
type: 'error', type: 'error',
payload: err.message message: err.message
}); });
} }
} }
@ -64,7 +69,7 @@ function concatenateScripts(scripts, callback) {
if (err) { if (err) {
process.send({ process.send({
type: 'error', type: 'error',
payload: err message: err.message
}); });
return; return;
} }

@ -126,11 +126,11 @@ module.exports = function(Meta) {
} }
break; break;
case 'error': 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(); minifier.kill();
if (typeof callback === 'function') { if (typeof callback === 'function') {
callback(new Error(message.payload)); callback(new Error(message.message));
} else { } else {
process.exit(0); process.exit(0);
} }

Loading…
Cancel
Save