How to use supports-hyperlinks - 8 common examples

To help you get started, we’ve selected a few supports-hyperlinks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sindresorhus / terminal-link / index.js View on Github external
// 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;
github cabal-club / cabal-cli / markdown-shim.js View on Github external
function linkify (text, url) {
  return supportsHyperlinks.stdout ? ansiEscapes.link(text, url) : `${text} (${url})`
}
github danger / danger-js / source / commands / init / state-setup.ts View on Github external
const folderName = capitalizeFirstLetter(camelCase(basename(osProcess.cwd())))
  const isTypeScript = checkForTypeScript()
  const isBabel = checkForBabel()
  const hasTravis = fs.existsSync(".travis.yml")
  const hasCircle = fs.existsSync("circle.yml")
  const ciType = hasTravis ? "travis" : hasCircle ? "circle" : "unknown"
  const repoSlug = getRepoSlug()
  const isGitHub = !!repoSlug

  return {
    isMac,
    isWindows,
    isTypeScript,
    isBabel,
    isAnOSSRepo: true,
    supportsHLinks: supportsHyperlinks.stdout,
    filename: isTypeScript ? "dangerfile.ts" : "dangerfile.js",
    botName: folderName + "Bot",
    hasSetUpAccount: false,
    hasCreatedDangerfile: false,
    hasSetUpAccountToken: false,
    repoSlug,
    ciType,
    isGitHub,
  }
}
github NealST / github-cli / src / lib / tools / hyperlinker.ts View on Github external
export default function getHyperlinkText(theurl: string): string {
  let thedata = ''
  if (supportsHyperlinks.stdout) {
    thedata = hyperlinker('点击查看详情', theurl)
  } else {
    thedata = theurl
  }
  return thedata
}
github prisma / lift / src / ink / DevInkComponent.tsx View on Github external
),
                  )}
                
              
            )}
          
        
        
          {warnings && warnings.length > 0 && onSubmitWarningsPrompt ? (
            
          ) : (
            <>
              
                
                  Studio endpoint: 
                  {supportsHyperlinks.stdout ? (
                    
                      http://localhost:{this.props.studioPort}/
                    
                  ) : (
                    http://localhost:{this.props.studioPort}/
                  )}
                
              
              {'─'.repeat(this.width)}
              
                
                  d: 
                  diff
github mikaelbr / marked-terminal / index.js View on Github external
var prot = decodeURIComponent(unescape(href))
        .replace(/[^\w:]/g, '')
        .toLowerCase();
    } catch (e) {
      return '';
    }
    if (prot.indexOf('javascript:') === 0) {
      return '';
    }
  }

  var hasText = text && text !== href;

  var out = '';

  if (supportsHyperlinks.stdout) {
    let link = ''
    if(text){
      link = this.o.href(this.emoji(text))
    }else{
      link = this.o.href(href)
    }
    out = ansiEscapes.link(link, href);
  }else{
    if (hasText) out += this.emoji(text) + ' (';
    out +=  this.o.href(href);
    if (hasText) out += ')';
  }
  return this.o.link(out);
};
github sindresorhus / terminal-link / index.js View on Github external
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;
github sindresorhus / eslint-formatter-pretty / index.js View on Github external
try {
				ruleUrl = data.rulesMeta[x.ruleId].docs.url;
			} catch (_) {
				try {
					ruleUrl = getRuleDocs(x.ruleId).url;
				} catch (_) {}
			}

			const line = [
				'',
				x.severity === 'warning' ? logSymbols.warning : logSymbols.error,
				' '.repeat(maxLineWidth - x.lineWidth) + chalk.dim(x.line + chalk.gray(':') + x.column),
				' '.repeat(maxColumnWidth - x.columnWidth) + x.message,
				' '.repeat(maxMessageWidth - x.messageWidth) +
				(ruleUrl && supportsHyperlink(process.stdout) ? ansiEscapes.link(chalk.dim(x.ruleId), ruleUrl) : chalk.dim(x.ruleId))
			];

			if (!showLineNumbers) {
				line.splice(2, 1);
			}

			return line.join('  ');
		}

		return '';
	}).join('\n') + '\n\n';

supports-hyperlinks

Detect if your terminal emulator supports hyperlinks

MIT
Latest version published 3 months ago

Package Health Score

78 / 100
Full package analysis