mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-08 05:30:40 +01:00
use build module instead of forking
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user