How to use cli-width - 2 common examples

To help you get started, we’ve selected a few cli-width 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 angelozerr / tern.java / core / ternjs / node_modules / tern-eslint / node_modules / eslint / node_modules / inquirer / lib / utils / screen-manager.js View on Github external
'use strict';
var _ = require('lodash');
var util = require('./readline');
var cliWidth = require('cli-width');
var stripAnsi = require('strip-ansi');

// Prevent crashes on environments where the width can't be properly detected
cliWidth.defaultWidth = 80;

var ScreenManager = module.exports = function (rl) {
  // These variables are keeping information to allow correct prompt re-rendering
  this.height = 0;
  this.extraLinesUnderPrompt = 0;

  this.rl = rl;
};

ScreenManager.prototype.render = function (content, opt) {
  opt = _.extend({ cursor: 0 }, opt || {});
  var cursorPos = this.rl._getCursorPos();

  this.rl.output.unmute();
  this.clean(this.extraLinesUnderPrompt);
github AdonisCommunity / create-adonis-ts-app / src / spinner.ts View on Github external
*
* (c) Harminder Virk 
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

import { Ora } from 'ora'
import cliWidth from 'cli-width'
import { yellow, dim } from 'kleur'

/**
 * Getting width of the stdout to put log messages
 * in one line
 */
const WIDTH = cliWidth()

/**
 * Log installing dependencies message
 */
export function logInstall (list: string[], spinner: Ora, dev: boolean) {
  const dependencies: string[] = []
  const spaceBetweenDependencies = 2

  let widthConsumed = 17 + 15

  for (let dependency of list) {
    if ((widthConsumed + dependency.length + spaceBetweenDependencies) > WIDTH) {
      break
    }

    /**

cli-width

Get stdout window width, with two fallbacks, tty and then a default.

ISC
Latest version published 1 year ago

Package Health Score

68 / 100
Full package analysis

Popular cli-width functions

Similar packages