内置终端增加自定义shell功能

This commit is contained in:
purocean
2019-08-06 15:56:34 +08:00
parent ee64cf554a
commit 4348c97a01
2 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -1,5 +1,4 @@
import * as fs from 'fs'
import * as os from 'os'
import * as path from 'path'
import * as Koa from 'koa'
import * as bodyParser from 'koa-body'
@@ -15,6 +14,7 @@ import dataRepository from './repository'
import run from './run'
import convert from './convert'
import plantuml from './plantuml'
import shell from './shell'
const result = (status = 'ok', message = '操作成功', data: any = null) => {
return { status, message, data }
@@ -203,7 +203,7 @@ const server = (port = 3000) => {
const io = require('socket.io')(server, {path: '/ws'})
io.on('connection', (socket: any) => {
const ptyProcess = pty.spawn(os.platform() === 'win32' ? 'cmd.exe' : 'bash', [], {
const ptyProcess = pty.spawn(shell.getShell(), [], {
name: 'xterm-color',
cols: 80,
rows: 24,
+14
View File
@@ -0,0 +1,14 @@
import config from './config'
import * as os from 'os'
const configKey = 'shell'
const defaultVal = os.platform() === 'win32' ? 'cmd.exe' : 'bash'
const getShell = () => {
return config.get(configKey, defaultVal)
}
export default {
getShell,
}