File tree Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Expand file tree Collapse file tree 2 files changed +11
-15
lines changed Original file line number Diff line number Diff line change @@ -109,11 +109,11 @@ export const ptyShell = (
109109 } ,
110110 type : ( text ) => {
111111 log ( 'type' , text ) ;
112- childProcess . send ( `${ text } \r` ) ;
112+ childProcess . stdin ! . write ( `${ text } \r` ) ;
113113 } ,
114114 press : ( key ) => {
115115 log ( 'press' , key ) ;
116- childProcess . send ( key ) ;
116+ childProcess . stdin ! . write ( key ) ;
117117 } ,
118118 } ) ;
119119
Original file line number Diff line number Diff line change 11/**
2- * node-pty is wrapped in an individual module instead of
3- * being called directly because it doesn't exist on Windows
4- *
2+ * This module wraps node-pty to isolate known Windows-specific issues:
53 * https://github.com/microsoft/node-pty/issues/437
4+ *
5+ * On Windows, killing a pty process can leave lingering sockets or handles,
6+ * preventing Node.js from exiting cleanly. By running node-pty in a separate
7+ * process, we can force a clean exit without hanging the main program or test runner.
68 */
79import { spawn } from 'node-pty' ;
810
911const [ file , ...args ] = process . argv . slice ( 2 ) ;
1012
11- const spawned = spawn ( file , args , {
12- cols : 1000 ,
13- } ) ;
13+ const ptyProcess = spawn ( file , args , { cols : 1000 } ) ;
1414
15- process . on ( 'message' , ( command ) => {
16- spawned . write ( command ) ;
17- } ) ;
15+ process . stdin . pipe ( ptyProcess ) ;
1816
19- spawned . onData ( ( data ) => {
20- process . stdout . write ( data ) ;
21- } ) ;
17+ ptyProcess . onData ( chunk => process . stdout . write ( chunk ) ) ;
2218
23- spawned . onExit ( ( { exitCode } ) => {
19+ ptyProcess . onExit ( ( { exitCode } ) => {
2420 // eslint-disable-next-line n/no-process-exit
2521 process . exit ( exitCode ) ;
2622} ) ;
You can’t perform that action at this time.
0 commit comments