From 3fe0e9c936003aa4b141716bd6c1ff03eff72368 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 12 Jul 2024 20:35:17 +1200 Subject: [PATCH] fix process .isTTY detection --- .changeset/six-kangaroos-jog.md | 5 +++++ packages/effect/src/internal/logger.ts | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 .changeset/six-kangaroos-jog.md diff --git a/.changeset/six-kangaroos-jog.md b/.changeset/six-kangaroos-jog.md new file mode 100644 index 0000000000..78d29846d4 --- /dev/null +++ b/.changeset/six-kangaroos-jog.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +fix process .isTTY detection diff --git a/packages/effect/src/internal/logger.ts b/packages/effect/src/internal/logger.ts index 40ccebe0bb..6571e1c603 100644 --- a/packages/effect/src/internal/logger.ts +++ b/packages/effect/src/internal/logger.ts @@ -416,9 +416,16 @@ const defaultDateFormat = (date: Date): string => date.getSeconds().toString().padStart(2, "0") }.${date.getMilliseconds().toString().padStart(3, "0")}` -const processStdoutIsTTY = typeof process === "object" && "stdout" in process && process.stdout.isTTY === true +const processStdoutIsTTY = typeof process === "object" && + process !== null && + typeof process.stdout === "object" && + process.stdout !== null && + process.stdout.isTTY === true const hasWindow = typeof window === "object" -const isWorker = typeof self === "object" && self.constructor && self.constructor.name.includes("Worker") +const isWorker = typeof self === "object" && + self !== null && + typeof self.constructor === "function" && + self.constructor.name.includes("Worker") /** @internal */ export const prettyLogger = (options?: {