mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature: terminal: get rid of mock-require
This commit is contained in:
parent
cfa3d69538
commit
4e32241d83
2 changed files with 15 additions and 18 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue