terminal-link
Advanced tools
Comparing version 2.1.1 to 3.0.0
@@ -1,41 +0,19 @@ | ||
declare namespace terminalLink { | ||
interface Options { | ||
/** | ||
Override the default fallback. If false, the fallback will be disabled. | ||
export interface Options { | ||
/** | ||
Override the default fallback. If false, the fallback will be disabled. | ||
@default `${text} (${url})` | ||
*/ | ||
fallback?: ((text: string, url: string) => string) | boolean; | ||
} | ||
@default `${text} (${url})` | ||
*/ | ||
readonly fallback?: ((text: string, url: string) => string) | boolean; | ||
} | ||
declare const terminalLink: { | ||
/** | ||
Create a clickable link in the terminal's stdout. | ||
readonly stderr: { | ||
/** | ||
Check whether the terminal's stderr supports links. | ||
[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) | ||
For unsupported terminals, the link will be printed in parens after the text: `My website (https://sindresorhus.com)`, | ||
unless the fallback is disabled by setting the `fallback` option to `false`. | ||
Prefer just using the default fallback or the `fallback` option whenever possible. | ||
*/ | ||
readonly isSupported: boolean; | ||
@param text - Text to linkify. | ||
@param url - URL to link to. | ||
@example | ||
``` | ||
import terminalLink = require('terminal-link'); | ||
const link = terminalLink('My Website', 'https://sindresorhus.com'); | ||
console.log(link); | ||
``` | ||
*/ | ||
(text: string, url: string, options?: terminalLink.Options): string; | ||
/** | ||
Check whether the terminal supports links. | ||
Prefer just using the default fallback or the `fallback` option whenever possible. | ||
*/ | ||
readonly isSupported: boolean; | ||
readonly stderr: { | ||
/** | ||
@@ -52,3 +30,3 @@ Create a clickable link in the terminal's stderr. | ||
``` | ||
import terminalLink = require('terminal-link'); | ||
import terminalLink from 'terminal-link'; | ||
@@ -59,13 +37,33 @@ const link = terminalLink.stderr('My Website', 'https://sindresorhus.com'); | ||
*/ | ||
(text: string, url: string, options?: terminalLink.Options): string; | ||
(text: string, url: string, options?: Options): string; | ||
}; | ||
/** | ||
Check whether the terminal's stderr supports links. | ||
/** | ||
Check whether the terminal supports links. | ||
Prefer just using the default fallback or the `fallback` option whenever possible. | ||
*/ | ||
readonly isSupported: boolean; | ||
} | ||
Prefer just using the default fallback or the `fallback` option whenever possible. | ||
*/ | ||
readonly isSupported: boolean; | ||
/** | ||
Create a clickable link in the terminal's stdout. | ||
[Supported terminals.](https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda) | ||
For unsupported terminals, the link will be printed in parens after the text: `My website (https://sindresorhus.com)`, | ||
unless the fallback is disabled by setting the `fallback` option to `false`. | ||
@param text - Text to linkify. | ||
@param url - URL to link to. | ||
@example | ||
``` | ||
import terminalLink from 'terminal-link'; | ||
const link = terminalLink('My Website', 'https://sindresorhus.com'); | ||
console.log(link); | ||
``` | ||
*/ | ||
(text: string, url: string, options?: Options): string; | ||
}; | ||
export = terminalLink; | ||
export default terminalLink; |
18
index.js
@@ -1,6 +0,5 @@ | ||
'use strict'; | ||
const ansiEscapes = require('ansi-escapes'); | ||
const supportsHyperlinks = require('supports-hyperlinks'); | ||
import ansiEscapes from 'ansi-escapes'; | ||
import supportsHyperlinks from 'supports-hyperlinks'; | ||
const terminalLink = (text, url, {target = 'stdout', ...options} = {}) => { | ||
export default function terminalLink(text, url, {target = 'stdout', ...options} = {}) { | ||
if (!supportsHyperlinks[target]) { | ||
@@ -16,9 +15,6 @@ // If the fallback has been explicitly disabled, don't modify the text itself. | ||
return ansiEscapes.link(text, url); | ||
}; | ||
} | ||
module.exports = (text, url, options = {}) => terminalLink(text, url, options); | ||
module.exports.stderr = (text, url, options = {}) => terminalLink(text, url, {target: 'stderr', ...options}); | ||
module.exports.isSupported = supportsHyperlinks.stdout; | ||
module.exports.stderr.isSupported = supportsHyperlinks.stderr; | ||
terminalLink.isSupported = supportsHyperlinks.stdout; | ||
terminalLink.stderr = (text, url, options = {}) => terminalLink(text, url, {target: 'stderr', ...options}); | ||
terminalLink.stderr.isSupported = supportsHyperlinks.stderr; |
{ | ||
"name": "terminal-link", | ||
"version": "2.1.1", | ||
"version": "3.0.0", | ||
"description": "Create clickable links in the terminal", | ||
@@ -11,9 +11,12 @@ "license": "MIT", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=12" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
"//test": "xo && ava && tsd", | ||
"test": "xo && tsd" | ||
}, | ||
@@ -36,11 +39,13 @@ "files": [ | ||
"dependencies": { | ||
"ansi-escapes": "^4.2.1", | ||
"supports-hyperlinks": "^2.0.0" | ||
"ansi-escapes": "^5.0.0", | ||
"supports-hyperlinks": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.3.0", | ||
"clear-module": "^4.0.0", | ||
"tsd": "^0.11.0", | ||
"xo": "^0.25.3" | ||
"ava": "^3.15.0", | ||
"tsd": "^0.14.0", | ||
"xo": "^0.38.2" | ||
}, | ||
"ava": { | ||
"serial": true | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# terminal-link [![Build Status](https://travis-ci.org/sindresorhus/terminal-link.svg?branch=master)](https://travis-ci.org/sindresorhus/terminal-link) | ||
# terminal-link | ||
@@ -16,3 +16,3 @@ > Create clickable links in the terminal | ||
```js | ||
const terminalLink = require('terminal-link'); | ||
import terminalLink from 'terminal-link'; | ||
@@ -19,0 +19,0 @@ const link = terminalLink('My Website', 'https://sindresorhus.com'); |
Sorry, the diff of this file is not supported yet
3
Yes
6312
66
+ Addedansi-escapes@5.0.0(transitive)
+ Addedtype-fest@1.4.0(transitive)
- Removedansi-escapes@4.3.2(transitive)
- Removedtype-fest@0.21.3(transitive)
Updatedansi-escapes@^5.0.0
Updatedsupports-hyperlinks@^2.2.0