mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
var winston = require('winston'),
|
||||
async = require('async');
|
||||
|
||||
module.exports = function(Plugins) {
|
||||
module.exports = function (Plugins) {
|
||||
Plugins.deprecatedHooks = {
|
||||
'filter:user.custom_fields': null, // remove in v1.1.0
|
||||
'filter:post.save': 'filter:post.create',
|
||||
@@ -15,8 +15,8 @@ module.exports = function(Plugins) {
|
||||
`data.method`*, the method called in that plugin
|
||||
`data.priority`, the relative priority of the method when it is eventually called (default: 10)
|
||||
*/
|
||||
Plugins.registerHook = function(id, data, callback) {
|
||||
callback = callback || function() {};
|
||||
Plugins.registerHook = function (id, data, callback) {
|
||||
callback = callback || function () {};
|
||||
function register() {
|
||||
Plugins.loadedHooks[data.hook] = Plugins.loadedHooks[data.hook] || [];
|
||||
Plugins.loadedHooks[data.hook].push(data);
|
||||
@@ -54,7 +54,7 @@ module.exports = function(Plugins) {
|
||||
}
|
||||
|
||||
if (typeof data.method === 'string' && data.method.length > 0) {
|
||||
method = data.method.split('.').reduce(function(memo, prop) {
|
||||
method = data.method.split('.').reduce(function (memo, prop) {
|
||||
if (memo && memo[prop]) {
|
||||
return memo[prop];
|
||||
} else {
|
||||
@@ -76,8 +76,8 @@ module.exports = function(Plugins) {
|
||||
}
|
||||
};
|
||||
|
||||
Plugins.fireHook = function(hook, params, callback) {
|
||||
callback = typeof callback === 'function' ? callback : function() {};
|
||||
Plugins.fireHook = function (hook, params, callback) {
|
||||
callback = typeof callback === 'function' ? callback : function () {};
|
||||
|
||||
var hookList = Plugins.loadedHooks[hook];
|
||||
var hookType = hook.split(':')[0];
|
||||
@@ -103,7 +103,7 @@ module.exports = function(Plugins) {
|
||||
return callback(null, params);
|
||||
}
|
||||
|
||||
async.reduce(hookList, params, function(params, hookObj, next) {
|
||||
async.reduce(hookList, params, function (params, hookObj, next) {
|
||||
if (typeof hookObj.method !== 'function') {
|
||||
if (global.env === 'development') {
|
||||
winston.warn('[plugins] Expected method for hook \'' + hook + '\' in plugin \'' + hookObj.id + '\' not found, skipping.');
|
||||
@@ -113,7 +113,7 @@ module.exports = function(Plugins) {
|
||||
|
||||
hookObj.method(params, next);
|
||||
|
||||
}, function(err, values) {
|
||||
}, function (err, values) {
|
||||
if (err) {
|
||||
winston.error('[plugins] ' + hook + ', ' + err.message);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ module.exports = function(Plugins) {
|
||||
if (!Array.isArray(hookList) || !hookList.length) {
|
||||
return callback();
|
||||
}
|
||||
async.each(hookList, function(hookObj, next) {
|
||||
async.each(hookList, function (hookObj, next) {
|
||||
|
||||
if (typeof hookObj.method !== 'function') {
|
||||
if (global.env === 'development') {
|
||||
@@ -144,18 +144,18 @@ module.exports = function(Plugins) {
|
||||
if (!Array.isArray(hookList) || !hookList.length) {
|
||||
return callback();
|
||||
}
|
||||
async.each(hookList, function(hookObj, next) {
|
||||
async.each(hookList, function (hookObj, next) {
|
||||
if (typeof hookObj.method === 'function') {
|
||||
var timedOut = false;
|
||||
|
||||
var timeoutId = setTimeout(function() {
|
||||
var timeoutId = setTimeout(function () {
|
||||
winston.warn('[plugins] Callback timed out, hook \'' + hook + '\' in plugin \'' + hookObj.id + '\'');
|
||||
timedOut = true;
|
||||
next();
|
||||
}, 5000);
|
||||
|
||||
try {
|
||||
hookObj.method(params, function() {
|
||||
hookObj.method(params, function () {
|
||||
clearTimeout(timeoutId);
|
||||
if (!timedOut) {
|
||||
next.apply(null, arguments);
|
||||
@@ -173,7 +173,7 @@ module.exports = function(Plugins) {
|
||||
}, callback);
|
||||
}
|
||||
|
||||
Plugins.hasListeners = function(hook) {
|
||||
Plugins.hasListeners = function (hook) {
|
||||
return !!(Plugins.loadedHooks[hook] && Plugins.loadedHooks[hook].length > 0);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user