mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-03 13:19:51 +01:00
filter missing less and css files from plugins
This commit is contained in:
21
src/meta.js
21
src/meta.js
@@ -373,15 +373,16 @@ var fs = require('fs'),
|
||||
path.join(__dirname, '../public/vendor/fontawesome/less')
|
||||
],
|
||||
source = '@import "./theme";\n@import "font-awesome";',
|
||||
x, numLESS, numCSS;
|
||||
x;
|
||||
|
||||
// Add the imports for each LESS file
|
||||
for(x=0,numLESS=plugins.lessFiles.length;x<numLESS;x++) {
|
||||
|
||||
plugins.lessFiles = filterMissingFiles(plugins.lessFiles);
|
||||
for(x=0; x<plugins.lessFiles.length; ++x) {
|
||||
source += '\n@import ".' + path.sep + plugins.lessFiles[x] + '";';
|
||||
}
|
||||
|
||||
// ... and for each CSS file
|
||||
for(x=0,numCSS=plugins.cssFiles.length;x<numCSS;x++) {
|
||||
plugins.cssFiles = filterMissingFiles(plugins.cssFiles);
|
||||
for(x=0; x<plugins.cssFiles.length; ++x) {
|
||||
source += '\n@import (inline) ".' + path.sep + plugins.cssFiles[x] + '";';
|
||||
}
|
||||
|
||||
@@ -420,6 +421,16 @@ var fs = require('fs'),
|
||||
});
|
||||
};
|
||||
|
||||
function filterMissingFiles(files) {
|
||||
return files.filter(function(file) {
|
||||
var exists = fs.existsSync(path.join(__dirname, '../node_modules', file));
|
||||
if (!exists) {
|
||||
winston.warn('[meta/css] File not found! ' + file);
|
||||
}
|
||||
return exists;
|
||||
});
|
||||
}
|
||||
|
||||
Meta.css.updateBranding = function() {
|
||||
var Settings = require('./settings');
|
||||
var branding = new Settings('branding', '0', {}, function() {
|
||||
|
||||
Reference in New Issue
Block a user