mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 03:55:55 +01:00
cleanup / lint
This commit is contained in:
@@ -184,29 +184,33 @@ var fs = require('fs'),
|
||||
Plugins.staticDirs[pluginData.id] = path.join(pluginPath, pluginData.staticDir);
|
||||
}
|
||||
|
||||
for(var key in pluginData.staticDirs) {
|
||||
(function(mappedPath) {
|
||||
if (pluginData.staticDirs.hasOwnProperty(mappedPath)) {
|
||||
if (Plugins.staticDirs[mappedPath]) {
|
||||
winston.warn('[plugins/' + pluginData.id + '] Mapped path (' + mappedPath + ') already specified!');
|
||||
} else if (!validMappedPath.test(mappedPath)) {
|
||||
winston.warn('[plugins/' + pluginData.id + '] Invalid mapped path specified: ' + mappedPath + '. Path must adhere to: ' + validMappedPath.toString());
|
||||
} else {
|
||||
realPath = pluginData.staticDirs[mappedPath];
|
||||
staticDir = path.join(pluginPath, realPath);
|
||||
function mapStaticDirs(mappedPath) {
|
||||
if (pluginData.staticDirs.hasOwnProperty(mappedPath)) {
|
||||
if (Plugins.staticDirs[mappedPath]) {
|
||||
winston.warn('[plugins/' + pluginData.id + '] Mapped path (' + mappedPath + ') already specified!');
|
||||
} else if (!validMappedPath.test(mappedPath)) {
|
||||
winston.warn('[plugins/' + pluginData.id + '] Invalid mapped path specified: ' + mappedPath + '. Path must adhere to: ' + validMappedPath.toString());
|
||||
} else {
|
||||
realPath = pluginData.staticDirs[mappedPath];
|
||||
staticDir = path.join(pluginPath, realPath);
|
||||
|
||||
(function(staticDir) {
|
||||
fs.exists(staticDir, function(exists) {
|
||||
if (exists) {
|
||||
Plugins.staticDirs[pluginData.id + '/' + mappedPath] = staticDir;
|
||||
} else {
|
||||
winston.warn('[plugins/' + pluginData.id + '] Mapped path \'' + mappedPath + ' => ' + staticDir + '\' not found.');
|
||||
}
|
||||
});
|
||||
}(staticDir));
|
||||
}
|
||||
(function(staticDir) {
|
||||
fs.exists(staticDir, function(exists) {
|
||||
if (exists) {
|
||||
Plugins.staticDirs[pluginData.id + '/' + mappedPath] = staticDir;
|
||||
} else {
|
||||
winston.warn('[plugins/' + pluginData.id + '] Mapped path \'' + mappedPath + ' => ' + staticDir + '\' not found.');
|
||||
}
|
||||
});
|
||||
}(staticDir));
|
||||
}
|
||||
}(key));
|
||||
}
|
||||
}
|
||||
|
||||
for(var key in pluginData.staticDirs) {
|
||||
if (pluginData.staticDirs.hasOwnProperty(key)) {
|
||||
mapStaticDirs(key);
|
||||
}
|
||||
}
|
||||
|
||||
next();
|
||||
@@ -262,8 +266,10 @@ var fs = require('fs'),
|
||||
|
||||
async.each(languages, function(pathToLang, next) {
|
||||
fs.readFile(pathToLang, function(err, file) {
|
||||
var json;
|
||||
|
||||
try {
|
||||
var json = JSON.parse(file.toString());
|
||||
json = JSON.parse(file.toString());
|
||||
} catch (err) {
|
||||
winston.error('[plugins] Unable to parse custom language file: ' + pathToLang + '\r\n' + err.stack);
|
||||
return next(err);
|
||||
@@ -370,7 +376,7 @@ var fs = require('fs'),
|
||||
// omg, after 6 months I finally realised what this does...
|
||||
// It adds the callback to the arguments passed-in, since the callback
|
||||
// is defined in *this* file (the async cb), and not the hooks themselves.
|
||||
var value = hookObj.method.apply(Plugins, value.concat(function() {
|
||||
value = hookObj.method.apply(Plugins, value.concat(function() {
|
||||
next(arguments[0], Array.prototype.slice.call(arguments, 1));
|
||||
}));
|
||||
|
||||
@@ -686,8 +692,10 @@ var fs = require('fs'),
|
||||
fs.readFile(path.join(file, 'plugin.json'), next);
|
||||
},
|
||||
function(configJSON, next) {
|
||||
var config;
|
||||
|
||||
try {
|
||||
var config = JSON.parse(configJSON);
|
||||
config = JSON.parse(configJSON);
|
||||
} catch (err) {
|
||||
winston.warn("Plugin: " + file + " is corrupted or invalid. Please check plugin.json for errors.");
|
||||
return next(err, null);
|
||||
|
||||
Reference in New Issue
Block a user