Skip to content

Commit aa4847b

Browse files
committed
feat: use import map for ansi-escapes and supports-hyperlinks
1 parent f434d33 commit aa4847b

File tree

3 files changed

+44
-21
lines changed

3 files changed

+44
-21
lines changed

deno.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@
4343
"@std/path": "jsr:@std/path@^1.1.3",
4444
"@std/streams": "jsr:@std/streams@^1.0.14",
4545
"@std/yaml": "jsr:@std/yaml@^1.0.10",
46+
"ansi-escapes": "npm:ansi-escapes@^7.2.0",
4647
"isomorphic-git": "npm:isomorphic-git@^1.35.1",
4748
"hash-wasm": "npm:hash-wasm@^4.12.0",
48-
"marked": "npm:marked@^15.0.4"
49+
"marked": "npm:marked@^15.0.4",
50+
"supports-hyperlinks": "npm:supports-hyperlinks@^4.4.0"
4951
},
5052
"tasks": {
5153
"test": "deno test -A src/"

deno.lock

Lines changed: 33 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/utils/output.ts

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ import { Table } from '@cliffy/table'
55
import * as colors from '@std/fmt/colors'
66
import { format as prettyBytes } from '@std/fmt/bytes'
77
import { marked } from 'marked'
8+
// Imported libraries from import map (deno.json)
9+
import supportsHyperlinks from 'supports-hyperlinks'
10+
import ansiEscapes from 'ansi-escapes'
11+
812
import type { SummaryOutput, ValidationResult } from '../types/validation-result.ts'
913
import type { Issue, Severity } from '../types/issues.ts'
1014
import type { DatasetIssues } from '../issues/datasetIssues.ts'
@@ -18,19 +22,6 @@ interface LoggingOptions {
1822
*
1923
* Returns the full output string with newlines
2024
*/
21-
function supportsHyperlinks(): boolean {
22-
// If NO_COLOR is set, usually we shouldn't render fancy links either
23-
if (Deno.env.get("NO_COLOR")) {
24-
return false;
25-
}
26-
// Check specifically for terminals that support it (like iTerm, VSCode, etc.)
27-
const termProgram = Deno.env.get("TERM_PROGRAM");
28-
if (["iTerm.app", "vscode", "Apple_Terminal"].includes(termProgram || "")) {
29-
return true;
30-
}
31-
return false;
32-
}
33-
3425
export function consoleFormat(
3526
result: ValidationResult,
3627
options?: LoggingOptions,
@@ -86,9 +77,10 @@ function renderTokens(tokenList: any[]): string {
8677
return colors.cyan(token.text)
8778

8879
case 'link':
89-
if (supportsHyperlinks()) {
90-
// OSC-8 Hyperlink Sequence
91-
return `\u001b]8;;${token.href}\u001b\\${token.text}\u001b]8;;\u001b\\`
80+
// Use the library to check for stdout support
81+
if (supportsHyperlinks.stdout) {
82+
// OSC-8 Hyperlink Sequence via ansi-escapes
83+
return ansiEscapes.link(token.text, token.href)
9284
} else {
9385
// Fallback for terminals without support
9486
return `${colors.blue(token.text)} (${colors.gray(token.href)})`

0 commit comments

Comments
 (0)