mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 19:56:48 +00:00

This reverts commit fce4b981ea
.
This was a breaking change and should have been marked semver-major.
The change that was made altered the output of util.format() and
util.inspect(). With how much those are used in the wild, this type of
change deserves more justification.
Fixes: https://github.com/nodejs/node/issues/8138
PR-URL: https://github.com/nodejs/node/pull/8143
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
|
|
const stream = require('stream');
|
|
const assert = require('assert');
|
|
const repl = require('repl');
|
|
|
|
var output = '';
|
|
const inputStream = new stream.PassThrough();
|
|
const outputStream = new stream.PassThrough();
|
|
outputStream.on('data', function(d) {
|
|
output += d;
|
|
});
|
|
|
|
const r = repl.start({
|
|
input: inputStream,
|
|
output: outputStream,
|
|
terminal: true
|
|
});
|
|
|
|
r.defineCommand('say1', {
|
|
help: 'help for say1',
|
|
action: function(thing) {
|
|
output = '';
|
|
this.write('hello ' + thing);
|
|
this.displayPrompt();
|
|
}
|
|
});
|
|
|
|
r.defineCommand('say2', function() {
|
|
output = '';
|
|
this.write('hello from say2');
|
|
this.displayPrompt();
|
|
});
|
|
|
|
inputStream.write('.help\n');
|
|
assert(/\nsay1\thelp for say1\n/.test(output), 'help for say1 not present');
|
|
assert(/\nsay2\t\n/.test(output), 'help for say2 not present');
|
|
inputStream.write('.say1 node developer\n');
|
|
assert(/> hello node developer/.test(output), 'say1 outputted incorrectly');
|
|
inputStream.write('.say2 node developer\n');
|
|
assert(/> hello from say2/.test(output), 'say2 outputted incorrectly');
|