v3 new release (#80)
This commit is contained in:
committed by
GitHub
parent
a767c8d3a1
commit
20d2b4f98d
23
node_modules/terminal-link/index.js
generated
vendored
Normal file
23
node_modules/terminal-link/index.js
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
const ansiEscapes = require('ansi-escapes');
|
||||
const supportsHyperlinks = require('supports-hyperlinks');
|
||||
|
||||
const terminalLink = (text, url, {target = 'stdout', ...options} = {}) => {
|
||||
if (!supportsHyperlinks[target]) {
|
||||
// If the fallback has been explicitly disabled, don't modify the text itself.
|
||||
if (options.fallback === false) {
|
||||
return text;
|
||||
}
|
||||
|
||||
return typeof options.fallback === 'function' ? options.fallback(text, url) : `${text} (\u200B${url}\u200B)`;
|
||||
}
|
||||
|
||||
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;
|
Reference in New Issue
Block a user