From 46420d8a0bda3c2787cc6f842f63b93c10e7a042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Thu, 6 Feb 2025 13:09:18 +0100 Subject: [PATCH] Update picocolors --- packages/babel-code-frame/package.json | 2 +- packages/babel-code-frame/src/defs.ts | 10 ---------- packages/babel-code-frame/src/index.ts | 5 +++-- yarn.lock | 9 ++++++++- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/babel-code-frame/package.json b/packages/babel-code-frame/package.json index 303e3b59de0f..337a74dc5564 100644 --- a/packages/babel-code-frame/package.json +++ b/packages/babel-code-frame/package.json @@ -18,7 +18,7 @@ "dependencies": { "@babel/helper-validator-identifier": "workspace:^", "js-tokens": "condition:BABEL_8_BREAKING ? ^8.0.0 : ^4.0.0", - "picocolors": "^1.0.0" + "picocolors": "^1.1.1" }, "devDependencies": { "import-meta-resolve": "^4.1.0", diff --git a/packages/babel-code-frame/src/defs.ts b/packages/babel-code-frame/src/defs.ts index b443bbc4b904..9ea221e56062 100644 --- a/packages/babel-code-frame/src/defs.ts +++ b/packages/babel-code-frame/src/defs.ts @@ -1,16 +1,6 @@ import picocolors, { createColors } from "picocolors"; import type { Colors, Formatter } from "picocolors/types"; -export function isColorSupported() { - return ( - // See https://github.com/alexeyraspopov/picocolors/issues/62 - typeof process === "object" && - (process.env.FORCE_COLOR === "0" || process.env.FORCE_COLOR === "false") - ? false - : picocolors.isColorSupported - ); -} - export type InternalTokenType = | "keyword" | "capitalized" diff --git a/packages/babel-code-frame/src/index.ts b/packages/babel-code-frame/src/index.ts index 4eb435f4e8db..d4012dffc941 100644 --- a/packages/babel-code-frame/src/index.ts +++ b/packages/babel-code-frame/src/index.ts @@ -1,4 +1,5 @@ -import { getDefs, isColorSupported } from "./defs.ts"; +import picocolors from "picocolors"; +import { getDefs } from "./defs.ts"; import { highlight } from "./highlight.ts"; export { highlight }; @@ -126,7 +127,7 @@ export function codeFrameColumns( opts: Options = {}, ): string { const shouldHighlight = - opts.forceColor || (isColorSupported() && opts.highlightCode); + opts.forceColor || (picocolors.isColorSupported && opts.highlightCode); const defs = getDefs(shouldHighlight); const lines = rawLines.split(NEWLINE); diff --git a/yarn.lock b/yarn.lock index e2b6dc9bb4a0..fd0ee163ee5f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -287,7 +287,7 @@ __metadata: "@babel/helper-validator-identifier": "workspace:^" import-meta-resolve: "npm:^4.1.0" js-tokens: "condition:BABEL_8_BREAKING ? ^8.0.0 : ^4.0.0" - picocolors: "npm:^1.0.0" + picocolors: "npm:^1.1.1" strip-ansi: "npm:^4.0.0" languageName: unknown linkType: soft @@ -13788,6 +13788,13 @@ __metadata: languageName: node linkType: hard +"picocolors@npm:^1.1.1": + version: 1.1.1 + resolution: "picocolors@npm:1.1.1" + checksum: 10/e1cf46bf84886c79055fdfa9dcb3e4711ad259949e3565154b004b260cd356c5d54b31a1437ce9782624bf766272fe6b0154f5f0c744fb7af5d454d2b60db045 + languageName: node + linkType: hard + "picomatch@npm:^2.0.4, picomatch@npm:^2.2.1, picomatch@npm:^2.2.3, picomatch@npm:^2.3.1": version: 2.3.1 resolution: "picomatch@npm:2.3.1"