-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repl: show reference errors during preview
This aligns the behavior with the one in the Firefox console. It will visualize ReferenceErrors in case the input has no possible completion and no buffered input. That way typos can already be highlighted before being evaluated. Signed-off-by: Ruben Bridgewater <[email protected]> PR-URL: #33282 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
- Loading branch information
1 parent
1a9771a
commit d33dcf1
Showing
4 changed files
with
89 additions
and
9 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,46 @@ | ||
// Previews in strict mode should indicate ReferenceErrors. | ||
|
||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
common.skipIfInspectorDisabled(); | ||
|
||
if (process.argv[2] === 'child') { | ||
const stream = require('stream'); | ||
const repl = require('repl'); | ||
class ActionStream extends stream.Stream { | ||
readable = true; | ||
run(data) { | ||
this.emit('data', `${data}`); | ||
this.emit('keypress', '', { ctrl: true, name: 'd' }); | ||
} | ||
resume() {} | ||
pause() {} | ||
} | ||
|
||
repl.start({ | ||
input: new ActionStream(), | ||
output: new stream.Writable({ | ||
write(chunk, _, next) { | ||
console.log(chunk.toString()); | ||
next(); | ||
} | ||
}), | ||
useColors: false, | ||
terminal: true | ||
}).inputStream.run('xyz'); | ||
} else { | ||
const assert = require('assert'); | ||
const { spawnSync } = require('child_process'); | ||
|
||
const result = spawnSync( | ||
process.execPath, | ||
['--use-strict', `${__filename}`, 'child'] | ||
); | ||
|
||
assert.match( | ||
result.stdout.toString(), | ||
/\/\/ ReferenceError: xyz is not defined/ | ||
); | ||
} |