From 10da0ea1997ef4bcc359a003852160b4343c59a0 Mon Sep 17 00:00:00 2001 From: lafkpages Date: Tue, 17 Oct 2023 19:25:21 +0200 Subject: [PATCH] Disable color output if $NO_COLOR is set --- src/log/colors.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/log/colors.ts b/src/log/colors.ts index 3bc8f9b..1dc5e99 100644 --- a/src/log/colors.ts +++ b/src/log/colors.ts @@ -9,6 +9,10 @@ let colors: typeof import("ansi-colors"); try { colors = await import("ansi-colors"); + + if (process.env.NO_COLOR) { + colors.enabled = false; + } } catch { // If ansi-colors is not installed, return a proxy that returns itself // when any property is accessed