mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
29 lines
591 B
JavaScript
29 lines
591 B
JavaScript
import {createRequire} from 'module';
|
|
import tryCatch from 'try-catch';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
const noop = (req, res, next) => {
|
|
next && next();
|
|
};
|
|
|
|
noop.listen = noop;
|
|
|
|
export default (config, arg) => {
|
|
if (!config('terminal'))
|
|
return noop;
|
|
|
|
const [e, terminalModule] = tryCatch(require, config('terminalPath'));
|
|
|
|
if (!e && !arg)
|
|
return terminalModule;
|
|
|
|
if (!e)
|
|
return terminalModule(arg);
|
|
|
|
config('terminal', false);
|
|
console.log(`cloudcmd --terminal: ${e.message}`);
|
|
|
|
return noop;
|
|
};
|
|
|