mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +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);
|
Plugins.staticDirs[pluginData.id] = path.join(pluginPath, pluginData.staticDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(var key in pluginData.staticDirs) {
|
function mapStaticDirs(mappedPath) {
|
||||||
(function(mappedPath) {
|
if (pluginData.staticDirs.hasOwnProperty(mappedPath)) {
|
||||||
if (pluginData.staticDirs.hasOwnProperty(mappedPath)) {
|
if (Plugins.staticDirs[mappedPath]) {
|
||||||
if (Plugins.staticDirs[mappedPath]) {
|
winston.warn('[plugins/' + pluginData.id + '] Mapped path (' + mappedPath + ') already specified!');
|
||||||
winston.warn('[plugins/' + pluginData.id + '] Mapped path (' + mappedPath + ') already specified!');
|
} else if (!validMappedPath.test(mappedPath)) {
|
||||||
} else if (!validMappedPath.test(mappedPath)) {
|
winston.warn('[plugins/' + pluginData.id + '] Invalid mapped path specified: ' + mappedPath + '. Path must adhere to: ' + validMappedPath.toString());
|
||||||
winston.warn('[plugins/' + pluginData.id + '] Invalid mapped path specified: ' + mappedPath + '. Path must adhere to: ' + validMappedPath.toString());
|
} else {
|
||||||
} else {
|
realPath = pluginData.staticDirs[mappedPath];
|
||||||
realPath = pluginData.staticDirs[mappedPath];
|
staticDir = path.join(pluginPath, realPath);
|
||||||
staticDir = path.join(pluginPath, realPath);
|
|
||||||
|
|
||||||
(function(staticDir) {
|
(function(staticDir) {
|
||||||
fs.exists(staticDir, function(exists) {
|
fs.exists(staticDir, function(exists) {
|
||||||
if (exists) {
|
if (exists) {
|
||||||
Plugins.staticDirs[pluginData.id + '/' + mappedPath] = staticDir;
|
Plugins.staticDirs[pluginData.id + '/' + mappedPath] = staticDir;
|
||||||
} else {
|
} else {
|
||||||
winston.warn('[plugins/' + pluginData.id + '] Mapped path \'' + mappedPath + ' => ' + staticDir + '\' not found.');
|
winston.warn('[plugins/' + pluginData.id + '] Mapped path \'' + mappedPath + ' => ' + staticDir + '\' not found.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}(staticDir));
|
}(staticDir));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}(key));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var key in pluginData.staticDirs) {
|
||||||
|
if (pluginData.staticDirs.hasOwnProperty(key)) {
|
||||||
|
mapStaticDirs(key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
@@ -262,8 +266,10 @@ var fs = require('fs'),
|
|||||||
|
|
||||||
async.each(languages, function(pathToLang, next) {
|
async.each(languages, function(pathToLang, next) {
|
||||||
fs.readFile(pathToLang, function(err, file) {
|
fs.readFile(pathToLang, function(err, file) {
|
||||||
|
var json;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var json = JSON.parse(file.toString());
|
json = JSON.parse(file.toString());
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
winston.error('[plugins] Unable to parse custom language file: ' + pathToLang + '\r\n' + err.stack);
|
winston.error('[plugins] Unable to parse custom language file: ' + pathToLang + '\r\n' + err.stack);
|
||||||
return next(err);
|
return next(err);
|
||||||
@@ -370,7 +376,7 @@ var fs = require('fs'),
|
|||||||
// omg, after 6 months I finally realised what this does...
|
// omg, after 6 months I finally realised what this does...
|
||||||
// It adds the callback to the arguments passed-in, since the callback
|
// 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.
|
// 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));
|
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);
|
fs.readFile(path.join(file, 'plugin.json'), next);
|
||||||
},
|
},
|
||||||
function(configJSON, next) {
|
function(configJSON, next) {
|
||||||
|
var config;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
var config = JSON.parse(configJSON);
|
config = JSON.parse(configJSON);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
winston.warn("Plugin: " + file + " is corrupted or invalid. Please check plugin.json for errors.");
|
winston.warn("Plugin: " + file + " is corrupted or invalid. Please check plugin.json for errors.");
|
||||||
return next(err, null);
|
return next(err, null);
|
||||||
|
|||||||
Reference in New Issue
Block a user