How to use the log-update.create function in log-update

To help you get started, we’ve selected a few log-update 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 EvanBacon / react-native-ink / src / modules / Instance / index.tsx View on Github external
this.rootNode.onImmediateRender = this.onRender;

      this.renderer = createRenderer({
        terminalWidth: options.stdout.columns,
      });
    } else {
      this.rootNode = dom.createNode('root');
      this.rootNode.onRender = this.onRender;

      this.renderer = createRenderer({
        terminalWidth: options.stdout.columns,
      });
    }

    this.log = logUpdate.create(options.stdout);
    this.throttledLog = options.debug
      ? this.log
      : throttle(this.log, {
          leading: true,
          trailing: true,
        } as any);

    // Ignore last render after unmounting a tree to prevent empty output before exit
    this.isUnmounted = false;

    // Store last output to only rerender when needed
    this.lastOutput = '';

    // This variable is used only in debug mode to store full static output
    // so that it's rerendered every time, not just new static parts, like in non-debug mode
    this.fullStaticOutput = '';
github vadimdemedes / ink / src / instance.js View on Github external
this.rootNode.onImmediateRender = this.onRender;

			this.renderer = createExperimentalRenderer({
				terminalWidth: options.stdout.columns
			});
		} else {
			this.rootNode = dom.createNode('root');
			this.rootNode.onRender = this.onRender;

			this.renderer = createRenderer({
				terminalWidth: options.stdout.columns
			});
		}

		this.log = logUpdate.create(options.stdout);
		this.throttledLog = options.debug ? this.log : throttle(this.log, {
			leading: true,
			trailing: true
		});

		// Ignore last render after unmounting a tree to prevent empty output before exit
		this.isUnmounted = false;

		// Store last output to only rerender when needed
		this.lastOutput = '';

		// This variable is used only in debug mode to store full static output
		// so that it's rerendered every time, not just new static parts, like in non-debug mode
		this.fullStaticOutput = '';

		if (options.experimental) {
github codekirei / node-multispinner / lib / voidOut.js View on Github external
module.exports = function() {
  // create writable stream
  const stream = new Writable()

  // ignore (do not print) chunk, just call next
  stream._write = (chunk, enc, next) => { next() }

  // use this stream for logUpdate calls
  return logUpdate.create(stream)
}
github codekirei / node-multispinner / test / methods / constructor.js View on Github external
it('LogUpdate to stream if testing is true', () => {
    const m = new Multispinner(spinners, {testing: true})
    assert.deepEqual(
      logUpdate.create().toString(),
      m.update.toString()
    )
  })
})
github quasarframework / quasar-cli / lib / webpack / plugin.progress.js View on Github external
const
  { ProgressPlugin } = require('webpack'),
  throttle = require('lodash.throttle'),
  { green, grey } = require('chalk'),
  log = require('../helpers/logger')('app:progress'),
  logUpdate = require('log-update'),
  ms = require('ms')

const
  isMinimalTerminal = require('../helpers/is-minimal-terminal'),
  logLine = isMinimalTerminal
    ? () => {}
    : logUpdate.create(process.stdout, { showCursor: true })

const
  compilations = {},
  barLength = 25,
  barItems = Array.apply(null, { length: barLength })

let maxLengthName = 0

function isRunningGlobally () {
  return Object.values(compilations).find(c => c.running) !== void 0
}

function renderBar (progress, color) {
  const width = progress * (barLength / 100)

  return barItems
github quasarframework / quasar / app / lib / webpack / plugin.progress.js View on Github external
const { ProgressPlugin } = require('webpack')
const throttle = require('lodash.throttle')
const { green, grey } = require('chalk')
const log = require('../helpers/logger')('app:progress')
const logUpdate = require('log-update')
const ms = require('ms')

const isMinimalTerminal = require('../helpers/is-minimal-terminal')
const logLine = isMinimalTerminal
  ? () => {}
  : logUpdate.create(process.stdout, { showCursor: true })

const compilations = {}
const barLength = 25
const barItems = Array.apply(null, { length: barLength })

let maxLengthName = 0

function isRunningGlobally () {
  return Object.values(compilations).find(c => c.running) !== void 0
}

function renderBar (progress, color) {
  const width = progress * (barLength / 100)

  return barItems
    .map((_, index) => index < width ? '█' : ' ')
github BestBuyAPIs / bestbuy-cli / index.js View on Github external
function run (opts, stdout, cb) {
  var bby
  var total = 0
  var cnt = 0
  var start = process.hrtime()
  var progressInterval
  var logUpdater = logUpdate.create(stdout)

  var output
  var parser

  try {
    bby = bestbuy({key: opts.key, debug: opts.debug})
  } catch (err) {
    return cb(err)
  }

  opts.format = opts.format.toLowerCase()

  var dataStream = bby[`${opts.resource}AsStream`](opts.query, {
    format: opts.format === 'csv' || opts.format === 'tsv' ? 'json' : opts.format,
    show: opts.show,
    sort: opts.sort
github andreypopp / sitegen / src / bin / OutputRenderer.js View on Github external
done() {
    this.flush();
    updateScreen.clear();
    updateScreen.done();
    this.release();
  },
};

export function writeSync(fd, msg, flush) {
  fs.writeSync(fd, msg);
  if (flush) {
    fs.fsyncSync(fd);
  }
}

let updateScreen  = logUpdate.create({
  write(msg) {
    writeSync(1, msg, false);
  }
});


export default OutputRenderer;
github kodie / progress-img / index.js View on Github external
if (this.options.height === 'auto' && this.options.width === 'auto') {
      fallbackFit = 'box'
    } else if (this.options.height === 'auto') {
      fallbackFit = 'width'
    } else if (this.options.width === 'auto') {
      fallbackFit = 'height'
    }

    var fallbackOptions = {
      fit: fallbackFit,
      height: this.options.height === 'auto' ? '100%' : this.options.height.replace('px', ''),
      width: this.options.width === 'auto' ? '100%' : this.options.width.replace('px', '')
    }
  }

  this.log = logUpdate.create(this.options.output)

  img.forEach(i => {
    var buffer

    if (Buffer.isBuffer(i)) {
      buffer = i
    } else if (i.indexOf('data:') === 0) {
      var parsed = parseDataUri(i)

      if (parsed) {
        buffer = parsed.data
      }
    } else if (i.indexOf('http://') === 0 || i.indexOf('https://') === 0) {
      var response = requestSync({ url: i, encoding: null })

      if (response) {
github SpencerCDixon / redux-cli / src / models / ui.js View on Github external
startProgress(string, customStream) {
    const stream = customStream || logUpdate.create(this.outputStream);
    if (this.writeLevelVisible(this.writeLevel)) {
      this.streaming = true;
      this.progressInterval = setInterval(() => {
        stream(
          `  ${chalk.green('loading:')} ${string} ${chalk.cyan.bold.dim(
            frame()
          )}`
        );
      }, 100);
    }
  }

log-update

Log by overwriting the previous output in the terminal. Useful for rendering progress bars, animations, etc.

MIT
Latest version published 7 months ago

Package Health Score

78 / 100
Full package analysis