v1.18.x
Julian Lam 11 years ago
parent 790b0f98d4
commit f6ea278b09

@ -243,7 +243,7 @@ var fs = require('fs'),
minFile: path.join(__dirname, '..', 'public/src/nodebb.min.js'),
get: function (callback) {
plugins.fireHook('filter:scripts.get', this.scripts, function(err, scripts) {
var mtime,
var ctime,
jsPaths = scripts.map(function (jsPath) {
jsPath = path.normalize(jsPath);
@ -267,12 +267,12 @@ var fs = require('fs'),
if (process.env.NODE_ENV !== 'development') {
async.parallel({
mtime: function (next) {
ctime: function (next) {
async.map(jsPaths, fs.stat, function (err, stats) {
async.reduce(stats, 0, function (memo, item, next) {
if(item) {
mtime = +new Date(item.mtime);
next(null, mtime > memo ? mtime : memo);
ctime = +new Date(item.ctime);
next(null, ctime > memo ? ctime : memo);
} else {
next(null, memo);
}
@ -286,14 +286,15 @@ var fs = require('fs'),
}
fs.stat(Meta.js.minFile, function (err, stat) {
next(err, +new Date(stat.mtime));
next(err, +new Date(stat.ctime));
});
}
}, function (err, results) {
if (results.minFile > results.mtime) {
if (results.minFile > results.ctime) {
winston.info('No changes to client-side libraries -- skipping minification');
callback(null, [path.relative(path.join(__dirname, '../public'), Meta.js.minFile)]);
} else {
winston.info('Minifying client-side libraries -- please wait');
Meta.js.minify(function () {
callback(null, [
path.relative(path.join(__dirname, '../public'), Meta.js.minFile)

Loading…
Cancel
Save