File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ function getRandomInt(){
3737}
3838
3939export interface Options extends SpawnOptions {
40+ /**
41+ * if binary is enabled message and stderr events will not be emitted
42+ */
4043 mode ?: 'text' | 'json' | 'binary'
4144 formatter ?: ( param :string ) => any
4245 parser ?: ( param :string ) => any
@@ -147,7 +150,7 @@ export class PythonShell extends EventEmitter{
147150 }
148151
149152 // listen to stderr and emit errors for incoming data
150- if ( this . stderr ) {
153+ if ( this . stderrParser && this . stderr ) {
151154 this . stderr . on ( 'data' , function ( data ) {
152155 errorData += '' + data ;
153156 self . receiveStderr ( data ) ;
Original file line number Diff line number Diff line change @@ -348,7 +348,8 @@ describe('PythonShell', function () {
348348 mode : 'binary'
349349 } ) ;
350350 pyshell . receive = function ( ) {
351- throw new Error ( 'should not emit messages in binary mode' ) ;
351+ done ( 'should not emit messages in binary mode' ) ;
352+ return undefined
352353 } ;
353354 pyshell . end ( done ) ;
354355 } ) ;
@@ -385,12 +386,12 @@ describe('PythonShell', function () {
385386 } ) . send ( 'hello' ) . send ( 'world' ) . end ( done ) ;
386387 } ) ;
387388 it ( 'should not be invoked when mode is "binary"' , function ( done ) {
388- let pyshell = new PythonShell ( 'echo_args.py' , {
389- args : [ 'hello' , 'world' ] ,
389+ let pyshell = new PythonShell ( 'stderrLogging.py' , {
390390 mode : 'binary'
391391 } ) ;
392392 pyshell . receiveStderr = function ( ) {
393- throw new Error ( 'should not emit stderr in binary mode' ) ;
393+ done ( 'should not emit stderr in binary mode' ) ;
394+ return undefined
394395 } ;
395396 pyshell . end ( done ) ;
396397 } ) ;
You can’t perform that action at this time.
0 commit comments