@@ -242,27 +242,28 @@ class Chrome extends EventEmitter {
242242 // establish the connection wrapper and start processing user commands
243243 _connect ( ) {
244244 return new Promise ( ( fulfill , reject ) => {
245- let wrapper ;
246245 try {
247- wrapper = this . process ? this . _createStdioWrapper ( ) : this . _createWebSocketWrapper ( ) ;
246+ this . _wrapper = this . process
247+ ? this . _createStdioWrapper ( )
248+ : this . _createWebSocketWrapper ( ) ;
248249 } catch ( err ) {
249250 // handle missing stdio streams, bad URLs...
250251 reject ( err ) ;
251252 return ;
252253 }
253254 // set up event handlers
254- wrapper . on ( 'open' , ( ) => {
255+ this . _wrapper . on ( 'open' , ( ) => {
255256 fulfill ( ) ;
256257 } ) ;
257- wrapper . on ( 'message' , ( data ) => {
258+ this . _wrapper . on ( 'message' , ( data ) => {
258259 const message = JSON . parse ( data ) ;
259260 this . _handleMessage ( message ) ;
260261 } ) ;
261- wrapper . on ( 'close' , ( code ) => {
262+ this . _wrapper . on ( 'close' , ( code ) => {
262263 this . _handleConnectionClose ( ) ;
263264 this . emit ( 'disconnect' ) ;
264265 } ) ;
265- wrapper . on ( 'error' , ( err ) => {
266+ this . _wrapper . on ( 'error' , ( err ) => {
266267 reject ( err ) ;
267268 } ) ;
268269 } ) ;
@@ -334,6 +335,7 @@ class Chrome extends EventEmitter {
334335 }
335336 } ) ;
336337 }
338+ get wrapper ( ) { return this . _wrapper ; }
337339}
338340
339341module . exports = Chrome ;
0 commit comments