temp
This commit is contained in:
19
packages/webshell/webshell-node/package.json
Normal file
19
packages/webshell/webshell-node/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "webshell-node",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "abearxiong <xiongxiao@xiongxiao.me>",
|
||||
"license": "MIT",
|
||||
"type": "module",
|
||||
"dependencies": {
|
||||
"node-pty": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kevisual/types": "^0.0.6"
|
||||
}
|
||||
}
|
||||
20
packages/webshell/webshell-node/src/index.ts
Normal file
20
packages/webshell/webshell-node/src/index.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import os from 'node:os';
|
||||
import pty, { IPty } from 'node-pty';
|
||||
|
||||
const shell: string = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
|
||||
console.log(shell);
|
||||
const ptyProcess: IPty = pty.spawn(shell, [], {
|
||||
name: 'xterm-color',
|
||||
cols: 80,
|
||||
rows: 30,
|
||||
cwd: process.env.HOME || '',
|
||||
env: process.env as NodeJS.ProcessEnv,
|
||||
});
|
||||
|
||||
ptyProcess.onData((data: string) => {
|
||||
process.stdout.write(data);
|
||||
});
|
||||
|
||||
ptyProcess.write('ls\r');
|
||||
ptyProcess.resize(100, 40);
|
||||
ptyProcess.write('ls\r');
|
||||
Reference in New Issue
Block a user