mirror of
https://github.com/denoland/deno.git
synced 2024-12-23 07:44:48 -05:00
fix(node/tty): fix tty.WriteStream.hasColor
with different args (#25094)
The check in `tty.WriteStream.prototype.hasColors()` was incorrect leading to the [`yoctocolors`](https://github.com/sindresorhus/yoctocolors) package not printing any colors. Fixes https://github.com/denoland/deno/issues/24407
This commit is contained in:
parent
c94c5cddb1
commit
48701c19f8
2 changed files with 8 additions and 1 deletions
|
@ -113,7 +113,10 @@ export class WriteStream extends Socket {
|
|||
* @returns {boolean}
|
||||
*/
|
||||
hasColors(count, env) {
|
||||
if (env === undefined && typeof count === "object") {
|
||||
if (
|
||||
env === undefined &&
|
||||
(count === undefined || typeof count === "object" && count !== null)
|
||||
) {
|
||||
env = count;
|
||||
count = 16;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,10 @@ Deno.test("[node/tty WriteStream.isTTY] returns true when fd is a tty", () => {
|
|||
|
||||
Deno.test("[node/tty WriteStream.hasColors] returns true when colors are supported", () => {
|
||||
assert(tty.WriteStream.prototype.hasColors() === !Deno.noColor);
|
||||
assert(tty.WriteStream.prototype.hasColors({}) === !Deno.noColor);
|
||||
|
||||
assert(tty.WriteStream.prototype.hasColors(1));
|
||||
assert(tty.WriteStream.prototype.hasColors(1, {}));
|
||||
});
|
||||
|
||||
Deno.test("[node/tty WriteStream.getColorDepth] returns current terminal color depth", () => {
|
||||
|
|
Loading…
Reference in a new issue