mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
28 lines
574 B
JavaScript
28 lines
574 B
JavaScript
'use strict';
|
|
|
|
const tryCatch = require('try-catch');
|
|
const config = require('./config');
|
|
|
|
const noop = () => {};
|
|
noop.listen = noop;
|
|
|
|
module.exports = (arg) => getTerminal(config('terminal'), arg);
|
|
|
|
function getTerminal(term, arg) {
|
|
if (!term)
|
|
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;
|
|
}
|
|
|