| 1 | declare namespace terminalLink {
|
|---|
| 2 | interface Options {
|
|---|
| 3 | /**
|
|---|
| 4 | Override the default fallback. If false, the fallback will be disabled.
|
|---|
| 5 |
|
|---|
| 6 | @default `${text} (${url})`
|
|---|
| 7 | */
|
|---|
| 8 | fallback?: ((text: string, url: string) => string) | boolean;
|
|---|
| 9 | }
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | declare const terminalLink: {
|
|---|
| 13 | /**
|
|---|
| 14 | Create a clickable link in the terminal's stdout.
|
|---|
| 15 |
|
|---|
| 16 | [Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda)
|
|---|
| 17 | For unsupported terminals, the link will be printed in parens after the text: `My website (https://sindresorhus.com)`,
|
|---|
| 18 | unless the fallback is disabled by setting the `fallback` option to `false`.
|
|---|
| 19 |
|
|---|
| 20 | @param text - Text to linkify.
|
|---|
| 21 | @param url - URL to link to.
|
|---|
| 22 |
|
|---|
| 23 | @example
|
|---|
| 24 | ```
|
|---|
| 25 | import terminalLink = require('terminal-link');
|
|---|
| 26 |
|
|---|
| 27 | const link = terminalLink('My Website', 'https://sindresorhus.com');
|
|---|
| 28 | console.log(link);
|
|---|
| 29 | ```
|
|---|
| 30 | */
|
|---|
| 31 | (text: string, url: string, options?: terminalLink.Options): string;
|
|---|
| 32 |
|
|---|
| 33 | /**
|
|---|
| 34 | Check whether the terminal supports links.
|
|---|
| 35 |
|
|---|
| 36 | Prefer just using the default fallback or the `fallback` option whenever possible.
|
|---|
| 37 | */
|
|---|
| 38 | readonly isSupported: boolean;
|
|---|
| 39 |
|
|---|
| 40 | readonly stderr: {
|
|---|
| 41 | /**
|
|---|
| 42 | Create a clickable link in the terminal's stderr.
|
|---|
| 43 |
|
|---|
| 44 | [Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda)
|
|---|
| 45 | For unsupported terminals, the link will be printed in parens after the text: `My website (https://sindresorhus.com)`.
|
|---|
| 46 |
|
|---|
| 47 | @param text - Text to linkify.
|
|---|
| 48 | @param url - URL to link to.
|
|---|
| 49 |
|
|---|
| 50 | @example
|
|---|
| 51 | ```
|
|---|
| 52 | import terminalLink = require('terminal-link');
|
|---|
| 53 |
|
|---|
| 54 | const link = terminalLink.stderr('My Website', 'https://sindresorhus.com');
|
|---|
| 55 | console.error(link);
|
|---|
| 56 | ```
|
|---|
| 57 | */
|
|---|
| 58 | (text: string, url: string, options?: terminalLink.Options): string;
|
|---|
| 59 |
|
|---|
| 60 | /**
|
|---|
| 61 | Check whether the terminal's stderr supports links.
|
|---|
| 62 |
|
|---|
| 63 | Prefer just using the default fallback or the `fallback` option whenever possible.
|
|---|
| 64 | */
|
|---|
| 65 | readonly isSupported: boolean;
|
|---|
| 66 | }
|
|---|
| 67 | };
|
|---|
| 68 |
|
|---|
| 69 | export = terminalLink;
|
|---|