@@ -25,7 +25,7 @@ var util = require('util'),
2525 vm = require ( 'vm' ) ,
2626 repl = require ( 'repl' ) ,
2727 inherits = util . inherits ,
28- fork = require ( 'child_process' ) . fork ;
28+ spawn = require ( 'child_process' ) . spawn ;
2929
3030exports . start = function ( argv , stdin , stdout ) {
3131 argv || ( argv = process . argv . slice ( 2 ) ) ;
@@ -39,7 +39,7 @@ exports.start = function(argv, stdin, stdout) {
3939 stdin = stdin || process . openStdin ( ) ;
4040 stdout = stdout || process . stdout ;
4141
42- var args = argv ,
42+ var args = [ '--debug-brk' ] . concat ( argv ) ,
4343 interface = new Interface ( stdin , stdout , args ) ;
4444
4545 stdin . resume ( ) ;
@@ -169,8 +169,6 @@ function Client() {
169169 this . scripts = { } ;
170170 this . breakpoints = [ ] ;
171171
172- this . isolates = process . features . isolates ;
173-
174172 // Note that 'Protocol' requires strings instead of Buffers.
175173 socket . setEncoding ( 'utf8' ) ;
176174 socket . on ( 'data' , function ( d ) {
@@ -1597,51 +1595,20 @@ Interface.prototype.trySpawn = function(cb) {
15971595 }
15981596 }
15991597
1600- var client = self . client = new Client ( ) ,
1601- connectionAttempts = 0 ;
1602-
16031598 if ( ! this . child ) {
1604- if ( client . isolates ) {
1605- this . child = fork ( this . args . shift ( ) , this . args , {
1606- thread : true ,
1607- debug : function ( d ) {
1608- d . onmessage = function ( event ) {
1609- client . _onResponse ( {
1610- headers : { } ,
1611- body : JSON . parse ( event )
1612- } ) ;
1613- } ;
1614-
1615- // Monkey patch client to send requests directly to debugger
1616- client . req = function ( req , cb ) {
1617- req . type = 'request' ;
1618- cb . request_seq = req . seq = this . protocol . reqSeq ++ ;
1619- this . _reqCallbacks . push ( cb ) ;
1620-
1621- d . write ( JSON . stringify ( req ) ) ;
1622- } ;
1623-
1624- client . emit ( 'ready' ) ;
1625-
1626- client . _onResponse ( {
1627- headers : { Type : 'connect' } ,
1628- body : { }
1629- } ) ;
1630- } ,
1631- debugBrk : true
1632- } ) ;
1633- this . child . kill = function ( ) {
1634- self . error ( 'isolate.kill is not implemented yet!' ) ;
1635- } ;
1636- } else {
1637- this . child = fork ( '--debug-brk' , this . args ) ;
1638- }
1599+ this . child = spawn ( process . execPath , this . args ) ;
1600+
1601+ this . child . stdout . on ( 'data' , this . childPrint . bind ( this ) ) ;
1602+ this . child . stderr . on ( 'data' , this . childPrint . bind ( this ) ) ;
16391603 }
16401604
16411605 this . pause ( ) ;
16421606
1607+ var client = self . client = new Client ( ) ,
1608+ connectionAttempts = 0 ;
1609+
16431610 client . once ( 'ready' , function ( ) {
1644- if ( ! client . isolates ) self . stdout . write ( ' ok\n' ) ;
1611+ self . stdout . write ( ' ok\n' ) ;
16451612
16461613 // Restore breakpoints
16471614 breakpoints . forEach ( function ( bp ) {
@@ -1689,14 +1656,11 @@ Interface.prototype.trySpawn = function(cb) {
16891656 function attemptConnect ( ) {
16901657 ++ connectionAttempts ;
16911658 self . stdout . write ( '.' ) ;
1692-
16931659 client . connect ( port , host ) ;
16941660 }
16951661
1696- if ( ! client . isolates ) {
1697- setTimeout ( function ( ) {
1698- self . print ( 'connecting..' , true ) ;
1699- attemptConnect ( ) ;
1700- } , 50 ) ;
1701- }
1662+ setTimeout ( function ( ) {
1663+ self . print ( 'connecting..' , true ) ;
1664+ attemptConnect ( ) ;
1665+ } , 50 ) ;
17021666} ;
0 commit comments