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 <ruben@bridgewater.de> PR-URL: https://github.com/nodejs/node/pull/33282 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
46 lines
1,021 B
JavaScript
46 lines
1,021 B
JavaScript
// 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/
|
|
);
|
|
}
|