terminalLink.cjs 653 B

123456789101112131415161718192021222324252627
  1. // NOTICE: This file is generated by Rollup. To modify it,
  2. // please instead edit the ESM counterpart and rebuild with Rollup (npm run build).
  3. 'use strict';
  4. const supportsHyperlinks = require('supports-hyperlinks');
  5. // ANSI escapes
  6. const OSC = '\u001B]';
  7. const BEL = '\u0007';
  8. const SEP = ';';
  9. /**
  10. * @see https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda
  11. *
  12. * @param {string} text
  13. * @param {string} url
  14. * @returns {string}
  15. */
  16. function terminalLink(text, url) {
  17. if (supportsHyperlinks.stdout) {
  18. return [OSC, '8', SEP, SEP, url, BEL, text, OSC, '8', SEP, SEP, BEL].join('');
  19. }
  20. return text;
  21. }
  22. module.exports = terminalLink;