jhmaster2000 / bun-repl

Experimental REPL for Bun
https://www.npmjs.com/package/bun-repl
MIT License
74 stars 8 forks source link

fix(repl): reject current line input on SIGINT, exit if empty line an… #9

Closed meetmangukiya closed 1 year ago

meetmangukiya commented 1 year ago

…d SIGINT

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

jhmaster2000 commented 1 year ago

Didn't know node repl did this, TIL, thanks 👍

meetmangukiya commented 1 year ago

Still not the same as node repl, you need to do twice on empty line on node to exit, but figured this was simpler and got the main feature done which is just clearing current line input

jhmaster2000 commented 1 year ago

That one I'm aware of, but bun REPL is also its own thing and doesn't have to match everything Node's REPL does 1:1, the line clearing one is useful, but the double-ctrl+c to exit just doesn't feel necessary.

We do still need though is to make ctrl+c be able to break a long-running script like an infinite loop and stuff, if you'd like to help out and take this on let me know, PRs always welcome, otherwise I'll probably get to it tomorrow or the day after.

meetmangukiya commented 1 year ago

Was just checking if this created a bug for multiline inputs like functions or classes. I don't think it is accepting that yet right? or did this break it?

jhmaster2000 commented 1 year ago

Nah it doesn't have multiline input yet, don't worry. Multiline input is actually harder than it seems because the way it works in Node is they check for specific errors based on their message/code and decide if that error is "recoverable" by allowing more input on further lines, but Bun and thus JSC errors are different from Node/V8 ones so the mapping has to be remade from scratch, plus we have the added layer of transpiler-sourced errors to account for too. So it'll probably be one of the later features to be added.