Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, {});
// Add more context api
contextModify.plugins = plugins;
contextModify.query = plugin.query;
contextModify.log = log;
contextModify.callback = callback;
contextModify.restart = () => {
console.log();
spmLog.info('dora', 'try to restart...');
process.send('restart');
};
if (name === 'middleware') {
contextModify.app.use(func.call(contextModify));
callback();
} else if (isGeneratorFn(func)) {
co.wrap(func).call(contextModify).then((val) => {
callback(null, val);
}, callback);
} else {
const funcResult = func.call(contextModify, memo);
if (funcResult && funcResult.then) {
funcResult
.then(result => {
callback(null, result);
})
.catch(callback)
.catch(err => {
throw new Error(err);
});
} else {
callback(null, funcResult);
if (completed && reason) {
errorAsErrorObject.message =
'Caught error after test environment was torn down\n\n' +
errorAsErrorObject.message;
throw errorAsErrorObject;
}
return reason ? reject(errorAsErrorObject) : resolve();
};
return fn.call(testContext, done);
}
let returnedValue;
if (isGeneratorFn(fn)) {
returnedValue = co.wrap(fn).call({});
} else {
try {
returnedValue = fn.call(testContext);
} catch (error) {
return reject(error);
}
}
// If it's a Promise, return it. Test for an object with a `then` function
// to support custom Promise implementations.
if (
typeof returnedValue === 'object' &&
returnedValue !== null &&
typeof returnedValue.then === 'function'
) {