test fro node-pty

This commit is contained in:
2025-03-18 21:48:17 +08:00
parent b6e0b142d8
commit 27ac19a045
5 changed files with 45 additions and 51 deletions

View File

@@ -1,3 +1 @@
import { useContextKey } from '@kevisual/use-config/context';
export { log, getLogPath } from './logger.ts';

View File

@@ -9,6 +9,8 @@ import { checkShowPage } from './window/page/index.ts';
import { closeProcess, createProcess } from './process/index.ts';
import { getElectronResourcePath, isMac } from './system/env.ts';
import { checkForUpdates } from './updater/index.ts';
// @ts-ignore
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

21
src/main/terminal/pty.ts Normal file
View File

@@ -0,0 +1,21 @@
import * as pty from 'node-pty';
export function createPty(cmd: string) {
const ptyProcess = pty.spawn(cmd, [], {
name: 'xterm-color',
cols: 80,
rows: 30,
cwd: process.env.HOME,
env: process.env,
});
ptyProcess.onData((data) => {
process.stdout.write(data);
});
ptyProcess.write('ls\r');
ptyProcess.resize(100, 40);
ptyProcess.write('ls\r');
}
createPty('ls');