This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
REPL net sockets should act like TTYs #2917
Labels
Comments
It looks like the first step it to allow Likely the inverse will be needed as well (passing a |
I was able to get it working as expected with a lot of hacking: // repl-server.js
var repl = require('repl')
var net = require('net')
// hack #1
process.stdin.resume()
net.createServer(function (socket) {
// hack #2
socket.isTTY = true
// hack #3
socket.getWindowSize = function () { return [ 80, 40 ] }
// hack #4
socket.cursorTo = require('tty').WriteStream.prototype.cursorTo
socket.clearLine = require('tty').WriteStream.prototype.clearLine
// hack #5
socket._emitKey = require('tty').ReadStream.prototype._emitKey
socket.on('data', function (b) {
socket._emitKey(b)
})
var r = repl.start('socket repl > ', socket)
// if REPLServer was an EE, and fired "exit", then this *would* work
/*r.on('exit', function () {
console.error('repl exit event, closing socket')
socket.end()
})*/
}).listen(1337) // repl-client.js
var tty = require('tty')
var net = require('net')
var sock = net.createConnection(1337)
sock.on('connect', function () {
process.stdin.resume();
tty.setRawMode(true)
})
process.stdin.pipe(sock)
sock.pipe(process.stdout)
sock.on('end', function () {
tty.setRawMode(false)
process.stdin.pause()
}) Would have posted as a gist but github is erroring on me :( |
So we need to:
Comments? |
This is great work, thanks. The value of a good interactive net REPL is perhaps hard to understand until you need to fix tricky problems in production. |
Fixed by #2922 :) |
richardlau
pushed a commit
to ibmruntimes/node
that referenced
this issue
Oct 13, 2015
* ICU 56 was just released yesterday. Update to it. * Notable changes: Unicode 8, CLDR 28, 2-3x number format perf, 20% improvement in Collator startup * more at http://site.icu-project.org/download/56 or in nodejs#2917 Also: * cleanup out/**/*.d and deps/icu on "make clean" * cleanup deps/icu on "vcbuild clean" When building from an non-clean directory, it's important to run `make clean` or `vcbuild clean` to remove the existing ICU 55 from the deps path before building. Fixes: nodejs/node#2917 PR-URL: nodejs/node#3281 Reviewed-By: James M Snell <jasnell@gmail.com>
richardlau
pushed a commit
to ibmruntimes/node
that referenced
this issue
Oct 13, 2015
* ICU 56 was just released yesterday. Update to it. * Notable changes: Unicode 8, CLDR 28, 2-3x number format perf, 20% improvement in Collator startup * more at http://site.icu-project.org/download/56 or in nodejs#2917 Also: * cleanup out/**/*.d and deps/icu on "make clean" * cleanup deps/icu on "vcbuild clean" When building from an non-clean directory, it's important to run `make clean` or `vcbuild clean` to remove the existing ICU 55 from the deps path before building. Fixes: nodejs/node#2917 PR-URL: nodejs/node#3281 Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It would be very useful if REPL net sockets could work like @TooTallNate ' s example:
https://gist.github.com/d9f15b31b60b09b84e54
So we could get readline functionality over REPL.
The text was updated successfully, but these errors were encountered: