@@ -31,13 +31,11 @@ type API = {
31
31
export const ptyShell = (
32
32
callback : ( api : API ) => Promise < void > ,
33
33
options ?: NodeOptions < 'utf8' > ,
34
- debugTitle ?: string ,
35
34
) => {
36
35
const timeStart = Date . now ( ) ;
36
+ const logs : string [ ] = [ ] ;
37
37
const log = ( ...messages : any [ ] ) => {
38
- if ( debugTitle ) {
39
- console . log ( `[${ debugTitle } ][${ Date . now ( ) - timeStart } ms]` , ...messages ) ;
40
- }
38
+ logs . push ( `[${ Date . now ( ) - timeStart } ms] ${ messages . map ( message => JSON . stringify ( message ) ) . join ( ' ' ) } ` ) ;
41
39
} ;
42
40
43
41
const childProcess = execaNode (
@@ -58,7 +56,7 @@ export const ptyShell = (
58
56
deferred . resolve ( line ) ;
59
57
lineMap . delete ( pattern ) ;
60
58
61
- log ( 'line' , JSON . stringify ( line ) ) ;
59
+ log ( 'line' , line ) ;
62
60
}
63
61
}
64
62
} ;
@@ -104,17 +102,17 @@ export const ptyShell = (
104
102
return promptDeferred . promise ;
105
103
} ,
106
104
waitForLine : ( pattern ) => {
107
- log ( 'waitForLine' , pattern ) ;
105
+ log ( 'waitForLine' , pattern . toString ( ) ) ;
108
106
const deferred = new Deferred < string > ( ) ;
109
107
lineMap . set ( pattern , deferred ) ;
110
108
return deferred . promise ;
111
109
} ,
112
110
type : ( text ) => {
113
- log ( 'type' , JSON . stringify ( text ) ) ;
111
+ log ( 'type' , text ) ;
114
112
childProcess . send ( `${ text } \r` ) ;
115
113
} ,
116
114
press : ( key ) => {
117
- log ( 'press' , JSON . stringify ( key ) ) ;
115
+ log ( 'press' , key ) ;
118
116
childProcess . send ( key ) ;
119
117
} ,
120
118
} ) ;
@@ -126,5 +124,8 @@ export const ptyShell = (
126
124
return stripAnsi ( buffer ) ;
127
125
} ) ( ) ;
128
126
129
- return Object . assign ( childProcess , { output } ) ;
127
+ return Object . assign ( childProcess , {
128
+ output,
129
+ logs,
130
+ } ) ;
130
131
} ;
0 commit comments