How to use the terminal-link.isSupported function in terminal-link

To help you get started, we’ve selected a few terminal-link 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 keystonejs / keystone / packages / app-graphql-playground / lib / devQuery.js View on Github external
// Store the loadable GraphiQL URL against that id
  const queryParams = buildGraphiqlQueryParams(req.body);
  devQueryLog[id] = `${graphiqlPath}?${queryParams}`;

  const ast = gql(req.body.query);

  const operations = ast.definitions.map(
    def => `${def.operation} ${def.name ? `${def.name.value} ` : ''}{ .. }`
  );

  // Make the queries clickable in the terminal where supported
  console.log(
    terminalLink(
      `${chalk.blue(operations.map(op => chalkColour.bold(op)).join(', '))}${
        terminalLink.isSupported ? ` (👈 click to view)` : ''
      }`,
      `${req.protocol}://${req.get('host')}${devQueryPath}?id=${id}`,
      {
        // Otherwise, show the link on a new line
        fallback: (text, url) => `${text}\n${chalkColour.gray(` ⤷ inspect @ ${url}`)}`,
      }
    )
  );

  // finally pass requests to the actual graphql endpoint
  next();
};
github sindresorhus / np / source / util.js View on Github external
exports.linkifyCommit = (url, commit) => {
	if (!(url && terminalLink.isSupported)) {
		return commit;
	}

	return terminalLink(commit, `${url}/commit/${commit}`);
};

terminal-link

Create clickable links in the terminal

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular terminal-link functions