Skip to content

Commit

Permalink
Update picocolors
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Feb 6, 2025
1 parent e02b0ff commit 46420d8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion packages/babel-code-frame/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 0 additions & 10 deletions packages/babel-code-frame/src/defs.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 3 additions & 2 deletions packages/babel-code-frame/src/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 8 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 46420d8

Please sign in to comment.