|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
837 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 | const ansiEscapes = require('ansi-escapes');
|
|---|
| 3 | const supportsHyperlinks = require('supports-hyperlinks');
|
|---|
| 4 |
|
|---|
| 5 | const terminalLink = (text, url, {target = 'stdout', ...options} = {}) => {
|
|---|
| 6 | if (!supportsHyperlinks[target]) {
|
|---|
| 7 | // If the fallback has been explicitly disabled, don't modify the text itself.
|
|---|
| 8 | if (options.fallback === false) {
|
|---|
| 9 | return text;
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | return typeof options.fallback === 'function' ? options.fallback(text, url) : `${text} (\u200B${url}\u200B)`;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | return ansiEscapes.link(text, url);
|
|---|
| 16 | };
|
|---|
| 17 |
|
|---|
| 18 | module.exports = (text, url, options = {}) => terminalLink(text, url, options);
|
|---|
| 19 |
|
|---|
| 20 | module.exports.stderr = (text, url, options = {}) => terminalLink(text, url, {target: 'stderr', ...options});
|
|---|
| 21 |
|
|---|
| 22 | module.exports.isSupported = supportsHyperlinks.stdout;
|
|---|
| 23 | module.exports.stderr.isSupported = supportsHyperlinks.stderr;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.