How to use has-ansi - 8 common examples

To help you get started, we’ve selected a few has-ansi 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 crawlab-team / crawlab / frontend / src / components / ScrollView / LogView.vue View on Github external
getItemProps (index) {
      const logItem = this.logData[index]
      const isAnsi = hasAnsi(logItem.data)
      return {
        //  will render with itemProps.
        // https://vuejs.org/v2/guide/render-function.html#createElement-Arguments
        props: {
          index: logItem.index,
          data: isAnsi ? convert.toHtml(logItem.data) : logItem.data,
          isAnsi
        }
      }
    }
  },
github ehmicky / log-process-errors / test / colors.js View on Github external
test.serial(`should colorize the error | ${title}`, async t => {
    const { stopLogging, log } = startLogging({ log: 'spy', eventName })

    await emit()

    t.true(log.calledOnce)
    t.false(hasAnsi(String(log.firstCall.args[0])))
    t.false(hasAnsi(log.firstCall.args[0].stack))
    t.is(hasAnsi(inspect(log.firstCall.args[0])), Boolean(supportsColor.stdout))

    stopLogging()
  })
github ehmicky / log-process-errors / test / colors.js View on Github external
test.serial(`should colorize the error | ${title}`, async t => {
    const { stopLogging, log } = startLogging({ log: 'spy', eventName })

    await emit()

    t.true(log.calledOnce)
    t.false(hasAnsi(String(log.firstCall.args[0])))
    t.false(hasAnsi(log.firstCall.args[0].stack))
    t.is(hasAnsi(inspect(log.firstCall.args[0])), Boolean(supportsColor.stdout))

    stopLogging()
  })
github ehmicky / nve / test / header.js View on Github external
test(`Prints headers in colors | ${title}`, async t => {
    const { stderr } = await run('', TEST_VERSION, 'node --version', {
      env: { FORCE_COLOR: '1' },
    })

    t.true(hasAnsi(stderr))
  })
})
github elastic / kibana / packages / kbn-pm / src / test_helpers / strip_ansi_snapshot_serializer.ts View on Github external
test(value: any) {
    return typeof value === 'string' && hasAnsi(value);
  },
};
github vpdb / server / src / app / common / logger.ts View on Github external
private colorMessage(message: string, prefixColor: any, messageColor?: any): string {
		if (hasAnsi(message)) {
			return config.vpdb.logging.console.colored ? message : stripAnsi(message);
		}
		if (!config.vpdb.logging.console.colored) {
			return message;
		}
		const match = message.match(/^(\[[^\]]+])(.+)/);
		if (match) {
			let prefix: string;
			if (prefixColor == null) {
				const m = match[1].split('.');
				prefix = m.length === 2 ?
					'[' + chalk.cyan(m[0].substring(1)) + '.' + chalk.blueBright(m[1].substring(0, m[1].length - 1)) + ']' :
					'[' + chalk.cyan(match[1].substring(1, match[1].length - 1)) + ']';
			} else {
				prefix = prefixColor(match[1]);
			}
github ansible / awx / awx / ui / client / lib / components / code / stdout.directive.js View on Github external
function createRow (ln, content) {
    content = content || '';

    if (hasAnsi(content)) {
        content = ansi.toHtml(content);
    }

    return `
        
            ${ln}
            ${content}
        `;
}
github expo / expo-cli / packages / dev-tools / components / Log.js View on Github external
renderMessageContent({ msg, level }) {
    if (!hasAnsi(msg)) {
      return (
        <div>
          {msg}
        </div>
      );
    }
    const chunks = ansiToJson(msg, {
      remove_empty: true,
    });
    const content = chunks.map(chunk =&gt; {
      const style = {};
      if (chunk.bg) {

has-ansi

Check if a string has ANSI escape codes

MIT
Latest version published 4 months ago

Package Health Score

75 / 100
Full package analysis

Popular has-ansi functions