-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugger: run last command on presssing enter
PR-URL: #6090 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Claudio Rodriguez <cjrodr@yahoo.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Fixes: #2895
- Loading branch information
Showing
5 changed files
with
82 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var a = 1; | ||
|
||
var b = 2; | ||
|
||
var c = 3; | ||
|
||
b = c; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
const path = require('path'); | ||
const spawn = require('child_process').spawn; | ||
const assert = require('assert'); | ||
|
||
const common = require('../common'); | ||
|
||
const fixture = path.join( | ||
common.fixturesDir, | ||
'debugger-repeat-last.js' | ||
); | ||
|
||
const args = [ | ||
'debug', | ||
fixture | ||
]; | ||
|
||
const proc = spawn(process.execPath, args, { stdio: 'pipe' }); | ||
proc.stdout.setEncoding('utf8'); | ||
|
||
var stdout = ''; | ||
|
||
var sentCommand = false; | ||
var sentEmpty = false; | ||
var sentExit = false; | ||
|
||
proc.stdout.on('data', (data) => { | ||
stdout += data; | ||
if (!sentCommand && stdout.includes('> 1')) { | ||
setImmediate(() => {proc.stdin.write('n\n');}); | ||
return sentCommand = true; | ||
} | ||
if (!sentEmpty && stdout.includes('> 3')) { | ||
setImmediate(() => {proc.stdin.write('\n');}); | ||
return sentEmpty = true; | ||
} | ||
if (!sentExit && sentCommand && sentEmpty) { | ||
setTimeout(() => {proc.stdin.write('\n\n\n.exit\n\n\n');}, 1); | ||
return sentExit = true; | ||
} | ||
}); | ||
|
||
process.on('exit', (exitCode) => { | ||
assert.strictEqual(exitCode, 0); | ||
console.log(stdout); | ||
}); |