mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -15,21 +15,21 @@ var db = require('../database');
|
||||
var file = require('../file');
|
||||
var utils = require('../../public/src/utils');
|
||||
|
||||
module.exports = function(Meta) {
|
||||
module.exports = function (Meta) {
|
||||
|
||||
Meta.css = {};
|
||||
Meta.css.cache = undefined;
|
||||
Meta.css.acpCache = undefined;
|
||||
|
||||
Meta.css.minify = function(callback) {
|
||||
callback = callback || function() {};
|
||||
Meta.css.minify = function (callback) {
|
||||
callback = callback || function () {};
|
||||
if (nconf.get('isPrimary') !== 'true') {
|
||||
winston.verbose('[meta/css] Cluster worker ' + process.pid + ' skipping LESS/CSS compilation');
|
||||
return callback();
|
||||
}
|
||||
|
||||
winston.verbose('[meta/css] Minifying LESS/CSS');
|
||||
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
|
||||
db.getObjectFields('config', ['theme:type', 'theme:id'], function (err, themeData) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -47,18 +47,18 @@ module.exports = function(Meta) {
|
||||
plugins.cssFiles = filterMissingFiles(plugins.cssFiles);
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
getStyleSource(plugins.lessFiles, '\n@import ".', '.less', next);
|
||||
},
|
||||
function(src, next) {
|
||||
function (src, next) {
|
||||
source += src;
|
||||
getStyleSource(plugins.cssFiles, '\n@import (inline) ".', '.css', next);
|
||||
},
|
||||
function(src, next) {
|
||||
function (src, next) {
|
||||
source += src;
|
||||
next();
|
||||
}
|
||||
], function(err) {
|
||||
], function (err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -84,7 +84,7 @@ module.exports = function(Meta) {
|
||||
var fromFile = nconf.get('from-file') || '';
|
||||
|
||||
async.series([
|
||||
function(next) {
|
||||
function (next) {
|
||||
if (fromFile.match('clientLess')) {
|
||||
winston.info('[minifier] Compiling front-end LESS files skipped');
|
||||
return Meta.css.getFromFile(path.join(__dirname, '../../public/stylesheet.css'), 'cache', next);
|
||||
@@ -92,7 +92,7 @@ module.exports = function(Meta) {
|
||||
|
||||
minify(source, paths, 'cache', next);
|
||||
},
|
||||
function(next) {
|
||||
function (next) {
|
||||
if (fromFile.match('acpLess')) {
|
||||
winston.info('[minifier] Compiling ACP LESS files skipped');
|
||||
return Meta.css.getFromFile(path.join(__dirname, '../../public/admin.css'), 'acpCache', next);
|
||||
@@ -100,7 +100,7 @@ module.exports = function(Meta) {
|
||||
|
||||
minify(acpSource, paths, 'acpCache', next);
|
||||
}
|
||||
], function(err, minified) {
|
||||
], function (err, minified) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ module.exports = function(Meta) {
|
||||
var pluginDirectories = [],
|
||||
source = '';
|
||||
|
||||
files.forEach(function(styleFile) {
|
||||
files.forEach(function (styleFile) {
|
||||
if (styleFile.endsWith(extension)) {
|
||||
source += prefix + path.sep + styleFile + '";';
|
||||
} else {
|
||||
@@ -134,27 +134,27 @@ module.exports = function(Meta) {
|
||||
}
|
||||
});
|
||||
|
||||
async.each(pluginDirectories, function(directory, next) {
|
||||
utils.walk(directory, function(err, styleFiles) {
|
||||
async.each(pluginDirectories, function (directory, next) {
|
||||
utils.walk(directory, function (err, styleFiles) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
styleFiles.forEach(function(styleFile) {
|
||||
styleFiles.forEach(function (styleFile) {
|
||||
source += prefix + path.sep + styleFile + '";';
|
||||
});
|
||||
|
||||
next();
|
||||
});
|
||||
}, function(err) {
|
||||
}, function (err) {
|
||||
callback(err, source);
|
||||
});
|
||||
}
|
||||
|
||||
Meta.css.commitToFile = function(filename, callback) {
|
||||
Meta.css.commitToFile = function (filename, callback) {
|
||||
var file = (filename === 'acpCache' ? 'admin' : 'stylesheet') + '.css';
|
||||
|
||||
fs.writeFile(path.join(__dirname, '../../public/' + file), Meta.css[filename], function(err) {
|
||||
fs.writeFile(path.join(__dirname, '../../public/' + file), Meta.css[filename], function (err) {
|
||||
if (!err) {
|
||||
winston.verbose('[meta/css] ' + file + ' committed to disk.');
|
||||
} else {
|
||||
@@ -166,10 +166,10 @@ module.exports = function(Meta) {
|
||||
});
|
||||
};
|
||||
|
||||
Meta.css.getFromFile = function(filePath, filename, callback) {
|
||||
Meta.css.getFromFile = function (filePath, filename, callback) {
|
||||
winston.verbose('[meta/css] Reading stylesheet ' + filePath.split('/').pop() + ' from file');
|
||||
|
||||
fs.readFile(filePath, function(err, file) {
|
||||
fs.readFile(filePath, function (err, file) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -183,7 +183,7 @@ module.exports = function(Meta) {
|
||||
less.render(source, {
|
||||
paths: paths,
|
||||
compress: true
|
||||
}, function(err, lessOutput) {
|
||||
}, function (err, lessOutput) {
|
||||
if (err) {
|
||||
winston.error('[meta/css] Could not minify LESS/CSS: ' + err.message);
|
||||
if (typeof callback === 'function') {
|
||||
@@ -201,7 +201,7 @@ module.exports = function(Meta) {
|
||||
|
||||
// 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)) {
|
||||
return Meta.css.commitToFile(destination, function() {
|
||||
return Meta.css.commitToFile(destination, function () {
|
||||
if (typeof callback === 'function') {
|
||||
callback(null, result.css);
|
||||
}
|
||||
@@ -217,7 +217,7 @@ module.exports = function(Meta) {
|
||||
}
|
||||
|
||||
function filterMissingFiles(files) {
|
||||
return files.filter(function(filePath) {
|
||||
return files.filter(function (filePath) {
|
||||
var exists = file.existsSync(path.join(__dirname, '../../node_modules', filePath));
|
||||
if (!exists) {
|
||||
winston.warn('[meta/css] File not found! ' + filePath);
|
||||
|
||||
Reference in New Issue
Block a user