From d5a55295a014409df7ddbbc04d7544240b26c666 Mon Sep 17 00:00:00 2001 From: Sergey Bronnikov Date: Tue, 24 Oct 2023 14:38:58 +0300 Subject: [PATCH] src: support NO_COLOR environment variable NO_COLOR is a de-facto standard environment variable for disabling colors, see [1]: > Command-line software which adds ANSI color to its output by default > should check for a NO_COLOR environment variable that, when present and > not an empty string (regardless of its value), prevents the addition of > ANSI color. The patch disables coloring when NO_COLOR is not empty. 1. https://no-color.org/ --- src/luacheck/format.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/luacheck/format.lua b/src/luacheck/format.lua index 96f39a5f..b073ddc6 100644 --- a/src/luacheck/format.lua +++ b/src/luacheck/format.lua @@ -4,6 +4,8 @@ local utils = require "luacheck.utils" local format = {} local color_support = not utils.is_windows or os.getenv("ANSICON") +-- Disable colors when NO_COLOR is set, see https://no-color.org/. +color_support = color_support and not os.getenv("NO_COLOR") local function get_message_format(warning) local message_format = assert(stages.warnings[warning.code], "Unkown warning code " .. warning.code).message_format