This commit is contained in:
2025-03-18 16:14:40 +08:00
parent 25def8c245
commit aa1cee7c9f
50 changed files with 916 additions and 502 deletions

View 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"
}
}

View 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');