mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
37 lines
866 B
JavaScript
37 lines
866 B
JavaScript
'use strict';
|
|
|
|
/* global CloudCmd */
|
|
|
|
CloudCmd.CommandLine = exports;
|
|
|
|
const Dialog = require('../dom/dialog');
|
|
|
|
module.exports.init = () => {};
|
|
|
|
module.exports.show = show;
|
|
module.exports.hide = hide;
|
|
|
|
async function show() {
|
|
const [, cmd] = await Dialog.prompt('Command Line', '');
|
|
const TERMINAL = '^(t|terminal)';
|
|
|
|
if (RegExp(`${TERMINAL}$`).test(cmd)) {
|
|
return await CloudCmd.Terminal.show();
|
|
}
|
|
|
|
if (RegExp(TERMINAL).test(cmd)) {
|
|
const command = cmd.replace(RegExp(`${TERMINAL} `), '');
|
|
const exitCode = await CloudCmd.TerminalRun.show({
|
|
command: `bash -c '${command}'`,
|
|
});
|
|
|
|
if (exitCode === -1)
|
|
await Dialog.alert(`☝️ Looks like Terminal is disabled, start Cloud Coammnder with '--terminal' flag.`);
|
|
|
|
return;
|
|
}
|
|
}
|
|
|
|
function hide() {
|
|
}
|
|
|