Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds '--clear-screen' option to clear screen between watch runs #3355

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

colinta
Copy link

@colinta colinta commented Nov 23, 2024

This is very slapped together, but I wanted it for myself and figured I'd start the conversation. If you are even open to mergin it let me know of any changes.

Usage:
npm test ava --watch --clear-scren 
What does this PR change?

Between test runs, it sends this.lineWriter.write(ansiEscapes.clearTerminal), which clears the screen and scrollback buffer on all the terminal apps I have handy.

I promoted this same behaviour in TypeScript, I guess it's my hill to die on 🤣 (in that case, --watch was already clearing the screen, this just changed/improved the behaviour).

Jest also clears the screen when using --watch. I prefer it, FWIW, but I've read the argument for keeping all those logs... I'm not convinced, but hey that's just me. I'd be happy w/ --clear-screen though it isn't exactly very discoverable atm.

WDYT?

@colinta
Copy link
Author

colinta commented Nov 23, 2024

When I first wrote this, I used process.stderr.write('\x1b[2J\x1b[H\x1b[3J');, but that felt wrong given the use of this.lineWriter.write so I switched to that... but now it doesn't work, so I switched it back to process.stderr.write. 🤷‍♂️

Correction: it works fine using lineWriter.

@sindresorhus
Copy link
Member

I have no opinion whether this should be added, but the flag should be --clear-screen.

@colinta colinta changed the title Adds '--cls' option to clear screen between watch runs Adds '--clear-screen' option to clear screen between watch runs Nov 23, 2024
@colinta
Copy link
Author

colinta commented Nov 23, 2024

I'm not personally a fan of the more verbose --clear-screenI chose cls for what I thought was a good reason – but I won't quibble. 🙂 (edit: that article points out that in *nix, the equivalent command would be clear, but I like --clear even less than --clear-screen, so --clear-screen is a decent compromise at the end of the day, and in the absence of other arguments, verbose/clarity beats all)

I gave this a short alias of -C, btw. Like/dislike? I'm not stuck on it.

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

Successfully merging this pull request may close these issues.

2 participants