feature: terminal: get rid of mock-require

This commit is contained in:
coderaiser 2024-03-22 10:52:25 +02:00
parent cfa3d69538
commit 4e32241d83
2 changed files with 15 additions and 18 deletions

View file

@ -8,11 +8,15 @@ const noop = (req, res, next) => {
noop.listen = noop;
module.exports = (config, arg) => {
function _getModule(a) {
return require(a);
}
module.exports = (config, arg, {getModule = _getModule} = {}) => {
if (!config('terminal'))
return noop;
const [e, terminalModule] = tryCatch(require, config('terminalPath'));
const [e, terminalModule] = tryCatch(getModule, config('terminalPath'));
if (!e && !arg)
return terminalModule;