test: move common.ArrayStream to separate module
In a continuing effort to de-monolithize `require('../common')`, move `common.ArrayStream` out to a separate module that is imported only when it is needed. PR-URL: https://github.com/nodejs/node/pull/22447 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
2d64a51270
commit
fa543c00cd
@ -38,9 +38,6 @@ tasks.
|
|||||||
|
|
||||||
Takes `whitelist` and concats that with predefined `knownGlobals`.
|
Takes `whitelist` and concats that with predefined `knownGlobals`.
|
||||||
|
|
||||||
### arrayStream
|
|
||||||
A stream to push an array into a REPL
|
|
||||||
|
|
||||||
### busyLoop(time)
|
### busyLoop(time)
|
||||||
* `time` [<number>]
|
* `time` [<number>]
|
||||||
|
|
||||||
@ -413,6 +410,20 @@ Platform normalizes the `pwd` command.
|
|||||||
|
|
||||||
Synchronous version of `spawnPwd`.
|
Synchronous version of `spawnPwd`.
|
||||||
|
|
||||||
|
## ArrayStream Module
|
||||||
|
|
||||||
|
The `ArrayStream` module provides a simple `Stream` that pushes elements from
|
||||||
|
a given array.
|
||||||
|
|
||||||
|
<!-- eslint-disable no-undef, node-core/required-modules -->
|
||||||
|
```js
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
|
const stream = new ArrayStream();
|
||||||
|
stream.run(['a', 'b', 'c']);
|
||||||
|
```
|
||||||
|
|
||||||
|
It can be used within tests as a simple mock stream.
|
||||||
|
|
||||||
## Countdown Module
|
## Countdown Module
|
||||||
|
|
||||||
The `Countdown` module provides a simple countdown mechanism for tests that
|
The `Countdown` module provides a simple countdown mechanism for tests that
|
||||||
|
24
test/common/arraystream.js
Normal file
24
test/common/arraystream.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* eslint-disable node-core/required-modules */
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const { Stream } = require('stream');
|
||||||
|
const { inherits } = require('util');
|
||||||
|
function noop() {}
|
||||||
|
|
||||||
|
// A stream to push an array into a REPL
|
||||||
|
function ArrayStream() {
|
||||||
|
this.run = function(data) {
|
||||||
|
data.forEach((line) => {
|
||||||
|
this.emit('data', `${line}\n`);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
inherits(ArrayStream, Stream);
|
||||||
|
ArrayStream.prototype.readable = true;
|
||||||
|
ArrayStream.prototype.writable = true;
|
||||||
|
ArrayStream.prototype.pause = noop;
|
||||||
|
ArrayStream.prototype.resume = noop;
|
||||||
|
ArrayStream.prototype.write = noop;
|
||||||
|
|
||||||
|
module.exports = ArrayStream;
|
@ -27,7 +27,6 @@ const fs = require('fs');
|
|||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const { exec, execSync, spawn, spawnSync } = require('child_process');
|
const { exec, execSync, spawn, spawnSync } = require('child_process');
|
||||||
const stream = require('stream');
|
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const { fixturesDir } = require('./fixtures');
|
const { fixturesDir } = require('./fixtures');
|
||||||
const tmpdir = require('./tmpdir');
|
const tmpdir = require('./tmpdir');
|
||||||
@ -511,23 +510,6 @@ exports.skip = function(msg) {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
// A stream to push an array into a REPL
|
|
||||||
function ArrayStream() {
|
|
||||||
this.run = function(data) {
|
|
||||||
data.forEach((line) => {
|
|
||||||
this.emit('data', `${line}\n`);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
util.inherits(ArrayStream, stream.Stream);
|
|
||||||
exports.ArrayStream = ArrayStream;
|
|
||||||
ArrayStream.prototype.readable = true;
|
|
||||||
ArrayStream.prototype.writable = true;
|
|
||||||
ArrayStream.prototype.pause = noop;
|
|
||||||
ArrayStream.prototype.resume = noop;
|
|
||||||
ArrayStream.prototype.write = noop;
|
|
||||||
|
|
||||||
// Returns true if the exit code "exitCode" and/or signal name "signal"
|
// Returns true if the exit code "exitCode" and/or signal name "signal"
|
||||||
// represent the exit code and/or signal name of a node process that aborted,
|
// represent the exit code and/or signal name of a node process that aborted,
|
||||||
// false otherwise.
|
// false otherwise.
|
||||||
|
@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
repl.start('', putIn, null, true);
|
repl.start('', putIn, null, true);
|
||||||
|
|
||||||
test1();
|
test1();
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
const vm = require('vm');
|
const vm = require('vm');
|
||||||
|
|
||||||
// Create a dummy stream that does nothing.
|
// Create a dummy stream that does nothing.
|
||||||
const stream = new common.ArrayStream();
|
const stream = new ArrayStream();
|
||||||
|
|
||||||
// Test context when useGlobal is false.
|
// Test context when useGlobal is false.
|
||||||
{
|
{
|
||||||
|
@ -20,11 +20,12 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
|
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
repl.start('', putIn);
|
repl.start('', putIn);
|
||||||
|
|
||||||
putIn.write = function(data) {
|
putIn.write = function(data) {
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
|
|
||||||
// \u001b[1G - Moves the cursor to 1st column
|
// \u001b[1G - Moves the cursor to 1st column
|
||||||
// \u001b[0J - Clear screen
|
// \u001b[0J - Clear screen
|
||||||
@ -11,7 +12,7 @@ const terminalCode = '\u001b[1G\u001b[0J> \u001b[3G';
|
|||||||
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');
|
const terminalCodeRegex = new RegExp(terminalCode.replace(/\[/g, '\\['), 'g');
|
||||||
|
|
||||||
function run({ input, output, event, checkTerminalCodes = true }) {
|
function run({ input, output, event, checkTerminalCodes = true }) {
|
||||||
const stream = new common.ArrayStream();
|
const stream = new ArrayStream();
|
||||||
let found = '';
|
let found = '';
|
||||||
|
|
||||||
stream.write = (msg) => found += msg.replace('\r', '');
|
stream.write = (msg) => found += msg.replace('\r', '');
|
||||||
@ -74,8 +75,8 @@ tests.forEach(run);
|
|||||||
|
|
||||||
// Auto code alignment for .editor mode
|
// Auto code alignment for .editor mode
|
||||||
function testCodeAligment({ input, cursor = 0, line = '' }) {
|
function testCodeAligment({ input, cursor = 0, line = '' }) {
|
||||||
const stream = new common.ArrayStream();
|
const stream = new ArrayStream();
|
||||||
const outputStream = new common.ArrayStream();
|
const outputStream = new ArrayStream();
|
||||||
|
|
||||||
stream.write = () => { throw new Error('Writing not allowed!'); };
|
stream.write = () => { throw new Error('Writing not allowed!'); };
|
||||||
|
|
||||||
|
@ -20,14 +20,15 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
let terminalExit = 0;
|
let terminalExit = 0;
|
||||||
let regularExit = 0;
|
let regularExit = 0;
|
||||||
|
|
||||||
// Create a dummy stream that does nothing
|
// Create a dummy stream that does nothing
|
||||||
const stream = new common.ArrayStream();
|
const stream = new ArrayStream();
|
||||||
|
|
||||||
function testTerminalMode() {
|
function testTerminalMode() {
|
||||||
const r1 = repl.start({
|
const r1 = repl.start({
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
{
|
{
|
||||||
const stream = new common.ArrayStream();
|
const stream = new ArrayStream();
|
||||||
const options = {
|
const options = {
|
||||||
eval: common.mustCall((cmd, context) => {
|
eval: common.mustCall((cmd, context) => {
|
||||||
assert.strictEqual(cmd, '.scope\n');
|
assert.strictEqual(cmd, '.scope\n');
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
@ -8,7 +9,7 @@ common.skipIfInspectorDisabled();
|
|||||||
|
|
||||||
// This test verifies that the V8 inspector API is usable in the REPL.
|
// This test verifies that the V8 inspector API is usable in the REPL.
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
let output = '';
|
let output = '';
|
||||||
putIn.write = function(data) {
|
putIn.write = function(data) {
|
||||||
output += data;
|
output += data;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
// Regression test for https://github.com/nodejs/node/issues/6802
|
// Regression test for https://github.com/nodejs/node/issues/6802
|
||||||
const input = new common.ArrayStream();
|
const input = new ArrayStream();
|
||||||
repl.start({ input, output: process.stdout, useGlobal: true });
|
repl.start({ input, output: process.stdout, useGlobal: true });
|
||||||
input.run(['let process']);
|
input.run(['let process']);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
@ -20,8 +21,8 @@ undefined
|
|||||||
|
|
||||||
let accum = '';
|
let accum = '';
|
||||||
|
|
||||||
const inputStream = new common.ArrayStream();
|
const inputStream = new ArrayStream();
|
||||||
const outputStream = new common.ArrayStream();
|
const outputStream = new ArrayStream();
|
||||||
|
|
||||||
outputStream.write = (data) => accum += data.replace('\r', '');
|
outputStream.write = (data) => accum += data.replace('\r', '');
|
||||||
|
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
const inputStream = new common.ArrayStream();
|
const inputStream = new ArrayStream();
|
||||||
const outputStream = new common.ArrayStream();
|
const outputStream = new ArrayStream();
|
||||||
const input = ['var foo = {', '};', 'foo;'];
|
const input = ['var foo = {', '};', 'foo;'];
|
||||||
let output = '';
|
let output = '';
|
||||||
|
|
||||||
|
@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
// Create a dummy stream that does nothing
|
// Create a dummy stream that does nothing
|
||||||
const stream = new common.ArrayStream();
|
const stream = new ArrayStream();
|
||||||
|
|
||||||
// 1, mostly defaults
|
// 1, mostly defaults
|
||||||
const r1 = repl.start({
|
const r1 = repl.start({
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
@ -8,8 +9,8 @@ const repl = require('repl');
|
|||||||
function run({ command, expected }) {
|
function run({ command, expected }) {
|
||||||
let accum = '';
|
let accum = '';
|
||||||
|
|
||||||
const inputStream = new common.ArrayStream();
|
const inputStream = new ArrayStream();
|
||||||
const outputStream = new common.ArrayStream();
|
const outputStream = new ArrayStream();
|
||||||
|
|
||||||
outputStream.write = (data) => accum += data.replace('\r', '');
|
outputStream.write = (data) => accum += data.replace('\r', '');
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
@ -8,8 +9,8 @@ const repl = require('repl');
|
|||||||
function run({ command, expected }) {
|
function run({ command, expected }) {
|
||||||
let accum = '';
|
let accum = '';
|
||||||
|
|
||||||
const inputStream = new common.ArrayStream();
|
const inputStream = new ArrayStream();
|
||||||
const outputStream = new common.ArrayStream();
|
const outputStream = new ArrayStream();
|
||||||
|
|
||||||
outputStream.write = (data) => accum += data.replace('\r', '');
|
outputStream.write = (data) => accum += data.replace('\r', '');
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
@ -14,7 +15,7 @@ function customEval(code, context, file, cb) {
|
|||||||
return cb(evalCount === 1 ? new repl.Recoverable() : null, true);
|
return cb(evalCount === 1 ? new repl.Recoverable() : null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
|
|
||||||
putIn.write = function(msg) {
|
putIn.write = function(msg) {
|
||||||
if (msg === '... ') {
|
if (msg === '... ') {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
@ -29,7 +29,7 @@ const util = require('util');
|
|||||||
common.allowGlobals(42);
|
common.allowGlobals(42);
|
||||||
|
|
||||||
// Create a dummy stream that does nothing
|
// Create a dummy stream that does nothing
|
||||||
const dummy = new common.ArrayStream();
|
const dummy = new ArrayStream();
|
||||||
|
|
||||||
function testReset(cb) {
|
function testReset(cb) {
|
||||||
const r = repl.start({
|
const r = repl.start({
|
||||||
|
@ -20,7 +20,8 @@
|
|||||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const join = require('path').join;
|
const join = require('path').join;
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
@ -32,7 +33,7 @@ const repl = require('repl');
|
|||||||
|
|
||||||
const works = [['inner.one'], 'inner.o'];
|
const works = [['inner.one'], 'inner.o'];
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
const testMe = repl.start('', putIn);
|
const testMe = repl.start('', putIn);
|
||||||
|
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'),
|
|||||||
'return "saved";',
|
'return "saved";',
|
||||||
'}'
|
'}'
|
||||||
];
|
];
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
const replServer = repl.start('', putIn);
|
const replServer = repl.start('', putIn);
|
||||||
|
|
||||||
putIn.run(['.editor']);
|
putIn.run(['.editor']);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
@ -10,7 +11,7 @@ process.on('exit', () => {
|
|||||||
assert.strictEqual(found, true);
|
assert.strictEqual(found, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
common.ArrayStream.prototype.write = function(output) {
|
ArrayStream.prototype.write = function(output) {
|
||||||
// Matching only on a minimal piece of the stack because the string will vary
|
// Matching only on a minimal piece of the stack because the string will vary
|
||||||
// greatly depending on the JavaScript engine. V8 includes `;` because it
|
// greatly depending on the JavaScript engine. V8 includes `;` because it
|
||||||
// displays the line of code (`var foo bar;`) that is causing a problem.
|
// displays the line of code (`var foo bar;`) that is causing a problem.
|
||||||
@ -20,7 +21,7 @@ common.ArrayStream.prototype.write = function(output) {
|
|||||||
found = true;
|
found = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
repl.start('', putIn);
|
repl.start('', putIn);
|
||||||
let file = fixtures.path('syntax', 'bad_syntax');
|
let file = fixtures.path('syntax', 'bad_syntax');
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
|
|
||||||
common.ArrayStream.prototype.write = () => {};
|
ArrayStream.prototype.write = () => {};
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
const testMe = repl.start('', putIn);
|
const testMe = repl.start('', putIn);
|
||||||
|
|
||||||
// https://github.com/nodejs/node/issues/3346
|
// https://github.com/nodejs/node/issues/3346
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
const DEFAULT_MAX_LISTENERS = require('events').defaultMaxListeners;
|
const DEFAULT_MAX_LISTENERS = require('events').defaultMaxListeners;
|
||||||
|
|
||||||
common.ArrayStream.prototype.write = () => {
|
ArrayStream.prototype.write = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
const testMe = repl.start('', putIn);
|
const testMe = repl.start('', putIn);
|
||||||
|
|
||||||
// https://github.com/nodejs/node/issues/18284
|
// https://github.com/nodejs/node/issues/18284
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
const common = require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const fixtures = require('../common/fixtures');
|
const fixtures = require('../common/fixtures');
|
||||||
const hasInspector = process.config.variables.v8_enable_inspector === 1;
|
const hasInspector = process.config.variables.v8_enable_inspector === 1;
|
||||||
@ -44,7 +45,7 @@ function getNoResultsFunction() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const works = [['inner.one'], 'inner.o'];
|
const works = [['inner.one'], 'inner.o'];
|
||||||
const putIn = new common.ArrayStream();
|
const putIn = new ArrayStream();
|
||||||
const testMe = repl.start('', putIn);
|
const testMe = repl.start('', putIn);
|
||||||
|
|
||||||
// Some errors are passed to the domain, but do not callback
|
// Some errors are passed to the domain, but do not callback
|
||||||
@ -525,7 +526,7 @@ testCustomCompleterAsyncMode.complete('a', common.mustCall((error, data) => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// tab completion in editor mode
|
// tab completion in editor mode
|
||||||
const editorStream = new common.ArrayStream();
|
const editorStream = new ArrayStream();
|
||||||
const editor = repl.start({
|
const editor = repl.start({
|
||||||
stream: editorStream,
|
stream: editorStream,
|
||||||
terminal: true,
|
terminal: true,
|
||||||
@ -548,7 +549,7 @@ editor.completer('var log = console.l', common.mustCall((error, data) => {
|
|||||||
|
|
||||||
{
|
{
|
||||||
// tab completion of lexically scoped variables
|
// tab completion of lexically scoped variables
|
||||||
const stream = new common.ArrayStream();
|
const stream = new ArrayStream();
|
||||||
const testRepl = repl.start({ stream });
|
const testRepl = repl.start({ stream });
|
||||||
|
|
||||||
stream.run([`
|
stream.run([`
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const common = require('../common');
|
require('../common');
|
||||||
|
const ArrayStream = require('../common/arraystream');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const { stripVTControlCharacters } = require('internal/readline');
|
const { stripVTControlCharacters } = require('internal/readline');
|
||||||
const repl = require('repl');
|
const repl = require('repl');
|
||||||
@ -9,7 +10,7 @@ const repl = require('repl');
|
|||||||
|
|
||||||
const PROMPT = 'await repl > ';
|
const PROMPT = 'await repl > ';
|
||||||
|
|
||||||
class REPLStream extends common.ArrayStream {
|
class REPLStream extends ArrayStream {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.waitingForResponse = false;
|
this.waitingForResponse = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user