use build module instead of forking

v1.18.x
barisusakli 8 years ago
parent 53fe432d8a
commit c32e6aaabb

@ -75,7 +75,7 @@ if (nconf.get('setup') || nconf.get('install')) {
} else if (nconf.get('reset')) {
async.waterfall([
async.apply(require('./src/reset').reset),
async.apply(require('./build').build, true)
async.apply(require('./build').buildAll)
], function (err) {
process.exit(err ? 1 : 0);
});
@ -257,7 +257,7 @@ function setup() {
async.series([
async.apply(install.setup),
async.apply(loadConfig),
async.apply(build.build, true)
async.apply(build.buildAll)
], function (err, data) {
// Disregard build step data
data = data[0];
@ -302,7 +302,7 @@ function upgrade() {
async.apply(db.init),
async.apply(meta.configs.init),
async.apply(upgrade.upgrade),
async.apply(build.build, true)
async.apply(build.buildAll)
], function (err) {
if (err) {
winston.error(err.stack);

@ -5,13 +5,19 @@ var winston = require('winston');
var buildStart;
var valid = ['js', 'clientCSS', 'acpCSS', 'tpl'];
exports.buildAll = function (callback) {
exports.build(valid.join(','), callback);
};
exports.build = function build(targets, callback) {
buildStart = Date.now();
var db = require('./src/database');
var meta = require('./src/meta');
var plugins = require('./src/plugins');
var valid = ['js', 'clientCSS', 'acpCSS', 'tpl'];
targets = (targets === true ? valid : targets.split(',').filter(function (target) {
return valid.indexOf(target) !== -1;

@ -23,6 +23,7 @@ define('admin/appearance/themes', ['translator'], function (translator) {
if (err) {
return app.alertError(err.message);
}
config['theme:id'] = themeId;
highlightSelectedTheme(themeId);
app.alert({

@ -153,15 +153,13 @@ module.exports = function (Meta) {
};
function minify(source, paths, destination, callback) {
callback = callback || function () {};
less.render(source, {
paths: paths
}, function (err, lessOutput) {
if (err) {
winston.error('[meta/css] Could not minify LESS/CSS: ' + err.message);
if (typeof callback === 'function') {
callback(err);
}
return;
return callback(err);
}
postcss([ autoprefixer, clean() ]).process(lessOutput.css).then(function (result) {
@ -171,19 +169,14 @@ module.exports = function (Meta) {
Meta.css[destination] = result.css;
// Save the compiled CSS in public/ so things like nginx can serve it
if (nconf.get('isPrimary') === 'true' && (nconf.get('local-assets') === undefined || nconf.get('local-assets') !== false)) {
if (nconf.get('local-assets') === undefined || nconf.get('local-assets') !== false) {
return Meta.css.commitToFile(destination, function () {
if (typeof callback === 'function') {
callback(null, result.css);
}
callback(null, result.css);
});
}
if (typeof callback === 'function') {
callback(null, result.css);
}
callback(null, result.css);
});
});
}

@ -62,14 +62,11 @@ SocketAdmin.reload = function (socket, data, callback) {
};
SocketAdmin.restart = function (socket, data, callback) {
// Rebuild assets and reload NodeBB
var child_process = require('child_process');
var build_worker = child_process.fork('app.js', ['--build'], {
cwd: path.join(__dirname, '../../'),
stdio: 'pipe'
});
require('../../build').buildAll(function (err) {
if (err) {
return callback(err)
}
build_worker.on('exit', function () {
events.log({
type: 'build',
uid: socket.uid,

Loading…
Cancel
Save