( options?: SupportsHyperlinksOptions, )
| 24 | * @param options Optional overrides for testing (env, stdoutSupported) |
| 25 | */ |
| 26 | export function supportsHyperlinks( |
| 27 | options?: SupportsHyperlinksOptions, |
| 28 | ): boolean { |
| 29 | const stdoutSupported = |
| 30 | options?.stdoutSupported ?? supportsHyperlinksLib.stdout |
| 31 | if (stdoutSupported) { |
| 32 | return true |
| 33 | } |
| 34 | |
| 35 | const env = options?.env ?? process.env |
| 36 | |
| 37 | // Check for additional terminals not detected by supports-hyperlinks |
| 38 | const termProgram = env['TERM_PROGRAM'] |
| 39 | if (termProgram && ADDITIONAL_HYPERLINK_TERMINALS.includes(termProgram)) { |
| 40 | return true |
| 41 | } |
| 42 | |
| 43 | // LC_TERMINAL is set by some terminals (e.g. iTerm2) and preserved inside tmux, |
| 44 | // where TERM_PROGRAM is overwritten to 'tmux'. |
| 45 | const lcTerminal = env['LC_TERMINAL'] |
| 46 | if (lcTerminal && ADDITIONAL_HYPERLINK_TERMINALS.includes(lcTerminal)) { |
| 47 | return true |
| 48 | } |
| 49 | |
| 50 | // Kitty sets TERM=xterm-kitty |
| 51 | const term = env['TERM'] |
| 52 | if (term?.includes('kitty')) { |
| 53 | return true |
| 54 | } |
| 55 | |
| 56 | return false |
| 57 | } |
| 58 |
no outgoing calls
no test coverage detected