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

Implement more robust isTTY check #63

Merged
merged 2 commits into from Sep 7, 2021

Conversation

kibertoad
Copy link
Collaborator

@kibertoad
Copy link
Collaborator Author

@jorgebucaran What's up with GitHub actions? I see there is a CI flow defined, but it doesn't seem to be running.

@mcollina
Copy link

mcollina commented Sep 5, 2021

I can confirm this fixes the compatibility problems we have for pino transport

@jorgebucaran
Copy link
Owner

Wow, thanks! So, is this Node's canonical way to detect if you are in a pipe? Other than not being available inside worker_threads, are there any disadvantages to process.stdout.isTTY? Curious.

@jorgebucaran jorgebucaran added the enhancement New feature or request label Sep 5, 2021
@jorgebucaran
Copy link
Owner

@jorgebucaran What's up with GitHub actions? I see there is a CI flow defined, but it doesn't seem to be running.

It was configured to run against push only. It's fixed now. 🙆‍♂️

@kibertoad
Copy link
Collaborator Author

@jorgebucaran This discussion might be useful: nodejs/node#28386

@mcollina
Copy link

mcollina commented Sep 7, 2021

@jorgebucaran is there an ETA for a release that would ship this?

index.js Outdated
@@ -1,12 +1,13 @@
const tty = require('tty');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Colorette is an ES module, so this should be changed to use import.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will that be compatible with current dual publishing of CJS and ES versions? do you autoreplace?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, looks like the time to upgrade that script has finally come! I can take care of that after we merge this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jorgebucaran
Copy link
Owner

Thanks! I'll merge here, update the script and publish a new minor version shortly.

@jorgebucaran jorgebucaran merged commit 9b6f41e into jorgebucaran:main Sep 7, 2021
@jorgebucaran
Copy link
Owner

Released as 1.4.0.

@kibertoad kibertoad deleted the fix/isatty branch September 7, 2021 18:52
@jorgebucaran
Copy link
Owner

@mcollina @kibertoad Is there any reason to check if tty is defined before using tty.isatty()? Should be defined, no?

import * as tty from "tty"
 ...
const isCompatibleTerminal =
  tty && tty.isatty(1) && env.TERM && env.TERM !== "dumb"

@kibertoad
Copy link
Collaborator Author

@jorgebucaran It's a node-specific thing. There were prior bug reports from people using colorette outside of Node, I wanted to safeguard against that from the get go.

@jorgebucaran
Copy link
Owner

Gotcha, thanks. I still feel that this should be handled by the user's bundler / preprocessor (#64 (comment)).

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

Successfully merging this pull request may close these issues.

None yet

3 participants