hooks: Check context nullness, not truthiness

This commit is contained in:
Richard Hansen 2021-02-01 00:37:45 -05:00 committed by John McLear
parent fd5d3ce777
commit c11d60c5f6

View file

@ -352,7 +352,7 @@ exports.aCallAll = async (hookName, context, cb = null) => {
};
exports.callFirst = (hookName, context) => {
if (!context) context = {};
if (context == null) context = {};
const predicate = (val) => val.length;
const hooks = pluginDefs.hooks[hookName] || [];
for (const hook of hooks) {
@ -366,7 +366,7 @@ exports.aCallFirst = async (hookName, context, cb = null, predicate = null) => {
if (cb != null) {
return await attachCallback(exports.aCallFirst(hookName, context, null, predicate), cb);
}
if (!context) context = {};
if (context == null) context = {};
if (predicate == null) predicate = (val) => val.length;
const hooks = pluginDefs.hooks[hookName] || [];
for (const hook of hooks) {