I quite like the example code in the readme. Nevertheless it might be a good idea to modernize some parts of the code to make it even easier to integrate node-pty into modern applications using "type": "module" or applications using typescript.
Proposed Changes
using import instead of require
using const instead of var
(optional) using 'node:os' import instead of os
import * as os from 'node:os';
import * as pty from 'node-pty';
const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';
const ptyProcess = pty.spawn(shell, [], {
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');
Issue description
I quite like the example code in the readme. Nevertheless it might be a good idea to modernize some parts of the code to make it even easier to integrate node-pty into modern applications using
"type": "module"
or applications using typescript.Proposed Changes
import
instead ofrequire
const
instead ofvar
'node:os'
import instead ofos