How to use the ansi-escapes.eraseLine function in ansi-escapes

To help you get started, we’ve selected a few ansi-escapes 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 Akryum / monorepo-run / src / run.js View on Github external
const print = (data) => {
    if (quiet || !data.trim()) return
    const clearingLine = hasClearLineRef.test(data)
    data = processOutput(data)
    if (lastOutputFolder !== folder) {
      if (lastOutputClearedLine) {
        process.stdout.write(ansiEscapes.eraseLine)
        process.stdout.write(ansiEscapes.cursorTo(0))
      }
      // Different folder => print folder tag
      process.stdout.write(printTag)
      if (clearingLine) {
        process.stdout.write('\n')
      }
    }

    process.stdout.write(data)
    lastOutputClearedLine = clearingLine ? folder : false
    lastOutputFolder = folder
  }
github avajs / ava / test / helper / tty-stream.js View on Github external
clearLine() {
		this.spinnerActivity.push(Buffer.from(ansiEscapes.eraseLine, 'ascii'));
	}
github derhuerst / build-wikipedia-feed / store-revisions.js View on Github external
const writeToHyperdrive = require('./lib/write-to-hyperdrive')

const FEED_VERSION = 2

const showError = (err) => {
	console.error(err)
	process.exit(1)
}

const dir = envPaths('p2p-wiki', {suffix: ''}).data
mkdirp.sync(dir)
const dbPath = path.join(dir, 'db')

let clear = '\n'
if (isatty(process.stderr.fd) && !isatty(process.stdout.fd)) {
	clear = esc.eraseLine + esc.cursorTo(0)
}
const report = (slug, revId) => {
	process.stderr.write(clear + slug + ' @ ' + revId)
}

let concurrency = process.env.CONCURRENCY
if (!concurrency || Number.isNaN(concurrency = parseInt(concurrency))) {
	concurrency = 4
}

const db = hyperdrive(dbPath)
db.ready((err) => {
	if (err) return showError(err)
	const keyAsHex = db.key.toString('hex')
	console.info(dbPath, keyAsHex)
github heroku / heroku-cli-util / lib / prompt.js View on Github external
return new Promise(function (resolve, reject) {
    let stdin = process.stdin
    let stderr = process.stderr
    let input = ''
    stdin.setEncoding('utf8')
    stderr.write(ansi.eraseLine)
    stderr.write(ansi.cursorLeft)
    cli.console.writeError(options.prompt)
    stdin.resume()
    stdin.setRawMode(true)

    function stop () {
      if (!options.hide) {
        stderr.write(
          ansi.cursorHide +
            ansi.cursorLeft +
            options.prompt +
            input.replace(/./g, '*') +
            '\n' +
            ansi.cursorShow)
      } else {
        stderr.write('\n')
github heroku / heroku-cli-util / lib / prompt.js View on Github external
return new Promise(function (resolve, reject) {
    let stdin = process.stdin
    let stderr = process.stderr
    let input = ''
    stdin.setEncoding('utf8')
    stderr.write(ansi.eraseLine)
    stderr.write(ansi.cursorLeft)
    cli.console.writeError(options.prompt)
    stdin.resume()
    stdin.setRawMode(true)

    function stop () {
      if (!options.hide) {
        stderr.write(
          ansi.cursorHide +
            ansi.cursorLeft +
            options.prompt +
            input.replace(/./g, '*') +
            '\n' +
            ansi.cursorShow)
      } else {
        stderr.write('\n')
github jest-community / jest-watch-typeahead / src / shared / pattern_prompt.js View on Github external
_onChange(pattern: string, options: ScrollOptions) {
    this._pipe.write(ansiEscapes.eraseLine);
    this._pipe.write(ansiEscapes.cursorLeft);
  }
}
github IndigoUnited / node-planify / reporters / spinner.js View on Github external
function printSequence(index, stdout) {
    index = (index < sequence.length - 1) ? index + 1 : 0;

    const str = chalk.bold(sequence[index]);

    stdout.write(ansiEscapes.eraseLine + ansiEscapes.cursorLeft);
    stdout.write(str);

    return index;
}
github derhuerst / date-prompt / index.js View on Github external
, render: function () {
		process.stdout.write(esc.eraseLine + esc.cursorTo(0)
		+ esc.cursorHide + [
			  ui.symbol(this.done, this.aborted)
			, chalk.bold(this.msg), ui.delimiter(false)
			, this.renderDigits(this.value, this.cursor, this.done)
		].join(' '))
	}
}
github voidcosmos / npkill / src / controller.ts View on Github external
private clearLine(row: number): void {
    this.printAt(ansiEscapes.eraseLine, { x: 0, y: row });
  }