You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@AriPerkkio Do you have some idea for fix? tty becoming false for users is not probably crucial per-se, but our own color logic not working on default setup seems bad.
Here's minimal reproduction without Tinypool demonstrating the fix from tinylibs/tinypool#104. Happy to change the implementation if another approach is found:
Intercept stdout of node:child_process in main process
I guess we could pass down some flag env: { __VITEST_ISATTY__: isatty(1)} from main thread to test runtime and create tinyrainbow instance manually by createColors(process.env.__VITEST_ISATTY__ === 'true') to at least save our own color.
Yup that should work! It makes sense that TTY checks start to fail after changing the streams. Not sure why colors should be disabled when TTY is disabled though.
Activity
hi-ogawa commentedon Dec 13, 2024
It turned out this is due to tinypool v1.0.2 tinylibs/tinypool#104.
@AriPerkkio Do you have some idea for fix?
ttybecomingfalsefor users is not probably crucial per-se, but our own color logic not working on default setup seems bad.Btw,
tinyrainbowis checkingisatty(1)and a few more conditions to decide enabling color https://github.com/tinylibs/tinyrainbow/blob/c8202ffc00d9f7f039ebdc2af52d08c6376fb6c0/src/node.ts#L6https://github.com/tinylibs/tinyrainbow/blob/c8202ffc00d9f7f039ebdc2af52d08c6376fb6c0/src/index.ts#L87-L93
AriPerkkio commentedon Dec 13, 2024
Good catch @hi-ogawa, I wasn't expecting this.
Here's minimal reproduction without Tinypool demonstrating the fix from tinylibs/tinypool#104. Happy to change the implementation if another approach is found:
Intercept stdout of node:child_process in main process
Intercept stdout of node:worker_threads, works automatically
hi-ogawa commentedon Dec 13, 2024
I guess we could pass down some flag
env: { __VITEST_ISATTY__: isatty(1)}from main thread to test runtime and createtinyrainbowinstance manually bycreateColors(process.env.__VITEST_ISATTY__ === 'true')to at least save our own color.AriPerkkio commentedon Dec 13, 2024
Yup that should work! It makes sense that TTY checks start to fail after changing the streams. Not sure why colors should be disabled when TTY is disabled though.
AriPerkkio commentedon Dec 15, 2024
@sheremet-va what do you think about having
process.env.FORCE_TTYhere? https://github.com/tinylibs/tinyrainbow/blob/c8202ffc00d9f7f039ebdc2af52d08c6376fb6c0/src/index.ts#L83-L97It could be used in cases like this, where main thread/process is TTY but spawned processes' streams aren't.