From 611475d271de8451646ee27a9d36a4f206018421 Mon Sep 17 00:00:00 2001 From: lread Date: Fri, 21 Jun 2024 22:16:54 -0400 Subject: [PATCH] force ansi colors on CI for tools-versions --- script/tools_versions.clj | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/script/tools_versions.clj b/script/tools_versions.clj index 7250e38..0e8ab1c 100644 --- a/script/tools_versions.clj +++ b/script/tools_versions.clj @@ -145,25 +145,27 @@ something exceptional happens." [& args] (when (main/doc-arg-opt args) - (println (ansi/compose "\n" - [:green (System/getProperty "os.name")] "\n" - " version: " (System/getProperty "os.version") "\n" - " arch: " (System/getProperty "os.arch"))) - (let [tools (versions)] - (doseq [{:keys [error name short-version path version]} tools] - (if error - (println (ansi/compose [:red name " - Error"] "\n" - [:red (-> error string/trim (string/replace #"(?m)^" " "))])) - (println (ansi/compose [:green name " " short-version] " - " path "\n" - (-> version string/trim (string/replace #"(?m)^" " ")))))) - ;; chrome/chromedriver and edge/edgedriver versions should match - (let [warnings (filter some? - [(version-mismatch tools "Chrome" "Chrome Webdriver") - (version-mismatch tools "Edge" "Edge Webdriver")])] - (when (seq warnings) - (println (ansi/compose "\n" [:red "Warnings"])) - (doseq [w warnings] - (println "-" w))))))) + ;; force colors on CI where is seems to be disabled by default + (binding [ansi/*color-enabled* (if (System/getenv "CI") true ansi/*color-enabled*)] + (println (ansi/compose "\n" + [:green (System/getProperty "os.name")] "\n" + " version: " (System/getProperty "os.version") "\n" + " arch: " (System/getProperty "os.arch"))) + (let [tools (versions)] + (doseq [{:keys [error name short-version path version]} tools] + (if error + (println (ansi/compose [:red name " - Error"] "\n" + [:red (-> error string/trim (string/replace #"(?m)^" " "))])) + (println (ansi/compose [:green name " " short-version] " - " path "\n" + (-> version string/trim (string/replace #"(?m)^" " ")))))) + ;; chrome/chromedriver and edge/edgedriver versions should match + (let [warnings (filter some? + [(version-mismatch tools "Chrome" "Chrome Webdriver") + (version-mismatch tools "Edge" "Edge Webdriver")])] + (when (seq warnings) + (println (ansi/compose "\n" [:red "Warnings"])) + (doseq [w warnings] + (println "-" w)))))))) (main/when-invoked-as-script (apply -main *command-line-args*))