DanielXMoore / Civet

A TypeScript superset that favors more types and less typing
https://civet.dev
MIT License
1.46k stars 30 forks source link

Civet eats output without trailing newline #1424

Closed bbrk24 closed 2 weeks ago

bbrk24 commented 2 weeks ago

MWE:

{ writeSync } from 'node:fs'
buf := Buffer.alloc 1, 0x61
writeSync 1, buf, 0, 1

When saved in mwe.civet, running civet mwe.civet produces no output, but civet -c --js mwe.civet -o .mjs && node mwe.mjs prints an "a" with no trailing newline. Adding process.stdout.write '\n' at the end of the program makes it print "a" with a trailing newline in both cases.

edemaine commented 2 weeks ago

It seems to work for me (on Node 22.9.0, on Windows and on Linux).

image

Is your shell overwriting the a? Above I'm using zsh with PROMPT_EOL_MARK="%S%F{green}[↩]%f%s"

bbrk24 commented 2 weeks ago

I just got a slow-mo video with my phone, and you seem to be right -- but even at 240 fps, it's barely noticeable.

https://github.com/user-attachments/assets/408727b8-cc94-4f2a-b5c0-e361dbd65a74

I feel like it's worth pointing out that for whatever reason it only overwrites that "a" when I run it with civet directly, and never when I compile it to JS and then run it with node.

bbrk24 commented 2 weeks ago

As for some environment differences: I'm on bash 5.1.16 (not zsh), and node 20.18 (not 22).

edemaine commented 2 weeks ago

Could it be npx causing the issue? What happens if you run civet directly?

bbrk24 commented 2 weeks ago

Wait, yes! It's npx's fault. What?!