Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Turn REPLServer into an EventEmitter and emit "exit" #2919

Closed
wants to merge 8 commits into from
Closed

Turn REPLServer into an EventEmitter and emit "exit" #2919

wants to merge 8 commits into from

Conversation

TooTallNate
Copy link

  1. The first commit (ac77cc08) fixes a very minor Windows bug.
  2. Second turns REPLServer into an EventEmitter
  3. Third makes REPLServer emit 'exit' events instead of 1) manually killing the processes (very bad!) or 2) simply pausing the stream (derefs stdout, but simply pauses a net.Socket).
  4. The next 3 could probably be squashed. They alter the behavior of when "SIGINT" is received on the readline socket. I think this new behavior is more expected. ae49ad43 shows the before and after.

This pull alone isn't enough to make a full featured repl work over a net.Socket with a clean API, but it's an unobtrusive start, and makes this hacky gist work for the time being: https://gist.github.com/2026110

@TooTallNate
Copy link
Author

The last 2 could also be squashed

@piscisaureus
Copy link

@TooTallNate Can you squash the last 2 commits. LGTM otherwise.

Windows was seeing: "C:\\path\\to\\cwd/repl"
This is because it should emit an "exit" event when "SIGINT" is received
from the readline interface, or when ".exit" is typed by the user.
This can happen when "SIGINT" is processed by the readline interface,
or when the user types ".exit" into the REPL.
It get's set to '' 1 line above, so we know that that's always 0.
Before:

☮ ~ (master) ⚡ node
> asdf
(^C again to quit)
> sdcasd☮ ~ (master) ⚡

Now:

☮ ~/node (repl) ⚡ ./node
> asfs
> sda
>
(^C again to quit)
> scdsdc
> sdcsdc
>
(^C again to quit)
> sdc
>
(^C again to quit)
>
☮ ~/node (repl) ⚡

^ note that each new line above is a ctrl+c sequence
@piscisaureus
Copy link

Landed in commits leading up to 884a209. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants