From 670dff3f0f9d05534ce6c9d2c705757aba0e56a7 Mon Sep 17 00:00:00 2001 From: Maciej Mensfeld Date: Thu, 26 Mar 2026 21:20:23 +0100 Subject: [PATCH] Fix picomatch basename option, add NO_COLOR support, bump engine to >=18.3 - Use picomatch's `basename` option instead of micromatch's `matchBase` - Respect NO_COLOR env var and non-TTY stdout for ANSI color output - Bump minimum Node.js engine to >=18.3.0 (parseArgs availability) --- package.json | 2 +- src/output/text.ts | 6 +++++- src/validator/glob.ts | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index bea0bcd..c720bdc 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ "author": "Maciej Mensfeld ", "license": "MIT", "engines": { - "node": ">=18.0.0" + "node": ">=18.3.0" }, "dependencies": { "fast-glob": "^3.3.2", diff --git a/src/output/text.ts b/src/output/text.ts index fef896e..8be3d02 100644 --- a/src/output/text.ts +++ b/src/output/text.ts @@ -5,7 +5,11 @@ import type { ValidationResult, Finding, StaleReason } from '../core/types.js'; /** Inline ANSI color helpers (replaces chalk) */ -const ansi = (code: number, close: number) => (s: string) => `\x1b[${code}m${s}\x1b[${close}m`; +const colorEnabled = + !('NO_COLOR' in process.env) && + (process.stdout.isTTY === true || process.env.FORCE_COLOR !== undefined); +const ansi = (code: number, close: number) => + colorEnabled ? (s: string) => `\x1b[${code}m${s}\x1b[${close}m` : (s: string) => s; const gray = ansi(90, 39); const yellow = ansi(33, 39); const red = ansi(31, 39); diff --git a/src/validator/glob.ts b/src/validator/glob.ts index 70bf93d..92a8ab6 100644 --- a/src/validator/glob.ts +++ b/src/validator/glob.ts @@ -35,7 +35,7 @@ export function globMatches( try { const isMatch = picomatch(normalizedPattern, { dot, - matchBase: !normalizedPattern.includes('/') + basename: !normalizedPattern.includes('/') }); return files.filter((file) => isMatch(file)); } catch {