added callbacks to css and js reloading, issue #2010

This commit is contained in:
Julian Lam
2014-08-25 10:13:01 -04:00
parent 3e033043f3
commit 0c4a788698
5 changed files with 32 additions and 14 deletions

View File

@@ -20,7 +20,7 @@ module.exports = function(Meta) {
Meta.css.branding = {};
Meta.css.defaultBranding = {};
Meta.css.minify = function() {
Meta.css.minify = function(callback) {
winston.info('[meta/css] Minifying LESS/CSS');
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'),
@@ -54,6 +54,9 @@ module.exports = function(Meta) {
parser.parse(source, function(err, tree) {
if (err) {
winston.error('[meta/css] Could not minify LESS/CSS: ' + err.message);
if (typeof callback === 'function') {
callback(err);
}
return;
}
@@ -63,6 +66,9 @@ module.exports = function(Meta) {
});
} catch (err) {
winston.error('[meta/css] Syntax Error: ' + err.message + ' - ' + path.basename(err.filename) + ' on line ' + err.line);
if (typeof callback === 'function') {
callback(err);
}
return;
}
@@ -89,6 +95,9 @@ module.exports = function(Meta) {
winston.info('[meta/css] Done.');
emitter.emit('meta:css.compiled');
if (typeof callback === 'function') {
callback();
}
});
});
};