How to use the strip-ansi function in strip-ansi

To help you get started, we’ve selected a few strip-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 MoOx / postcss-cssnext / docs / src / modules / playground / index.js View on Github external
function transformCSS() {
    const css = opts.from.value;

    opts.console.innerHTML = "";
    opts.messages.textContent = "";

    try {
      const result = transformer.process(css);
      opts.to.value = result.css.trim();
      const messages = result.warnings();
      if (messages.length) {
        opts.messages.textContent = `${bullet} ${stripColor(
          messages.map(message => message.toString())
        ).join("\n\n\n" + bullet + " ")}`;
      }
    } catch (e) {
      console.error(e);
      opts.to.value = "";
      opts.console.innerHTML =
        '<small class="cssnext-Playground-console-footer"><br><br>' +
        "If you think it's a bug, please " +
        '<a href="https://github.com/MoOx/postcss-cssnext/issues">' +
        "report it</a>." +
        "<br><small><em>cssnext v" +
        cssnextVersion +
        "</em></small></small>";
      // use createTextNode to escape html entities
      opts.console.insertBefore(
github zeit / next.js / packages / next / client / dev / error-overlay / hot-dev-client.js View on Github external
// Print warnings to the console.
  const formatted = formatWebpackMessages({
    warnings: warnings,
    errors: [],
  })

  if (typeof console !== 'undefined' &amp;&amp; typeof console.warn === 'function') {
    for (let i = 0; i &lt; formatted.warnings.length; i++) {
      if (i === 5) {
        console.warn(
          'There were more warnings in other files.\n' +
            'You can find a complete log in the terminal.'
        )
        break
      }
      console.warn(stripAnsi(formatted.warnings[i]))
    }
  }
}
github lnlfps / symph-joy / client / dev-error-overlay / hot-dev-client.js View on Github external
isFirstCompilation = false
  hasCompileErrors = true

  // "Massage" webpack messages.
  var formatted = formatWebpackMessages({
    errors: errors,
    warnings: []
  })

  // Only show the first error.
  ErrorOverlay.reportBuildError(formatted.errors[0])

  // Also log them to the console.
  if (typeof console !== 'undefined' &amp;&amp; typeof console.error === 'function') {
    for (var i = 0; i &lt; formatted.errors.length; i++) {
      console.error(stripAnsi(formatted.errors[i]))
    }
  }
}
github ehmicky / gulp-execa / test / helpers / normalize.js View on Github external
export const normalizeMessage = function(message) {
  const messageA = stripAnsi(message)
  const messageB = REPLACEMENTS.reduce(replacePart, messageA)
  const messageC = messageB.trim()
  return messageC
}
github forcedotcom / salesforcedx-vscode / packages / salesforcedx-vscode-lwc / src / testSupport / testIndexer / jestUtils.ts View on Github external
export function sanitizeFailureMessage(failureMessage: string) {
  return stripAnsi(failureMessage);
}
github prisma / lift / src / ink / DevInkComponent.tsx View on Github external
public getDiff = () => {
    const { datamodelBefore, datamodelAfter } = this.props
    const diff = printDatamodelDiff(datamodelBefore, datamodelAfter)
    return { diff, rowCount: stripAnsi(diff).split('\n').length }
  }
  public componentDidMount() {
github rocjs / roc / src / documentation / helpers.js View on Github external
export function addPadding(string, length) {
    string = string || '';
    return string + pad(length - stripAnsi(string).length);
}
github milesj / boost / packages / args / src / render.ts View on Github external
return values.reduce((sum, value) => {
      const text = stripAnsi(value);

      return text.length > sum ? text.length : sum;
    }, 0);
  }
github vpdb / server / src / app / common / logger.ts View on Github external
private splitMessage(message: string) {
		message = stripAnsi(message);
		const match = message.match(/^\[([^\s\]]+)]:?\s+(.+)/i);
		if (match) {
			return { module: match[1], message: match[2].trim(), type: 'app' };
		}
		return { message: message.trim(), type: 'app' };
	}

strip-ansi

Strip ANSI escape codes from a string

MIT
Latest version published 11 months ago

Package Health Score

74 / 100
Full package analysis

Popular strip-ansi functions