From e07cd6ce46e590bb2530d50d60835b47cc96da6c Mon Sep 17 00:00:00 2001 From: Mitsunee <19474909+Mitsunee@users.noreply.github.com> Date: Mon, 25 Nov 2024 00:56:17 +0100 Subject: [PATCH] fix: color middleware test in CI --- src/formatName.ts | 2 +- tests/formatName.test.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/formatName.ts b/src/formatName.ts index 2c9ff10..7c37517 100644 --- a/src/formatName.ts +++ b/src/formatName.ts @@ -1,7 +1,7 @@ import { padStr } from "./padStr"; import type { ResolvedLevelOpts } from "./types"; -const colorSupport = { +export const colorSupport = { stdout: process.stdout?.hasColors?.() ?? false, stderr: process.stderr?.hasColors?.() ?? false }; diff --git a/tests/formatName.test.ts b/tests/formatName.test.ts index 5dad955..bd8bb65 100644 --- a/tests/formatName.test.ts +++ b/tests/formatName.test.ts @@ -1,9 +1,17 @@ import { test } from "uvu"; import * as assert from "uvu/assert"; -import * as col from "picocolors"; -import { formatName } from "../src/formatName"; +import * as picocolors from "picocolors"; +import { colorSupport, formatName } from "../src/formatName"; import type { ResolvedLevelOpts } from "../src/types"; +console.log( + `Color Support detected: + stdout: ${colorSupport.stdout} (${colorSupport.stdout ? "Using color in tests" : "⚠️ Disabling color in tests"}) + stderr: ${colorSupport.stderr}` +); + +const col = picocolors.createColors(colorSupport.stdout); + test("transform name variables in template", () => { const level: ResolvedLevelOpts<"test"> = { name: "test",