How to use color-support - 5 common examples

To help you get started, we’ve selected a few color-support 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 jeroenouw / liftr-tscov / src / tscov / tscov.ts View on Github external
import 'reflect-metadata'
import minimist from 'minimist'
import * as path from 'path'
import * as packageJson from '../../package.json'
import { red, green, cyan, white, default as kleur } from 'kleur'

import { inject, injectable } from 'inversify'
import { CheckTypes } from './check-types'
import { Options } from './options'
import { MinCoverage } from './min-coverage'

const figlet = require('figlet')

kleur.enabled = require('color-support').level

@injectable()
export class Tscov {
  public suppressError: boolean = false

  constructor(
    @inject('Options') private options: Options,
    @inject('CheckTypes') private checkTypes: CheckTypes,
    @inject('MinCoverage') private minCoverage: MinCoverage
  ) {
    try {
      this.executeTscov()
        .then(success => {
          this.showSpacesLog()
          if (!success && !this.suppressError) {
            process.exit(1)
github mehmet-erim / symlink-manager / src / utils / log.js View on Github external
import ora from 'ora';
import kleur from 'kleur';
kleur.enabled = require('color-support').level;

export class Log {
  static log(text, color) {
    console.log(kleur[color]().bold(text));
  }

  static info(text) {
    this.log(text, 'cyan');
  }

  static primary(text) {
    this.log(text, 'blue');
  }

  static success(text) {
    this.log(text, 'green');
github tabarra / txAdmin / src / scripts / setup.js View on Github external
//Test environment conditions
const helpers = require('../extras/helpers');
helpers.dependencyChecker();

//Requires
const os = require('os');
const fs = require('fs-extra');
const readline = require('readline');
const { promisify } = require('util');
const axios = require("axios");
const ac = require('ansi-colors');
ac.enabled = require('color-support').hasBasic;
const { dir, log, logOk, logWarn, logError, cleanTerminal } = require('../extras/console');
cleanTerminal()
const context = 'SetupScript';
const printDivider = () => { log('='.repeat(64), context) };



//================================================================
//=================================================== Setup
//================================================================
//Setting up ReadLine
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
readline.Interface.prototype.question[promisify.custom] = function (prompt) {
    return new Promise(resolve =>
        readline.Interface.prototype.question.call(this, prompt, resolve),
    );
github tabarra / txAdmin / src / extras / console.js View on Github external
const ac = require('ansi-colors');
ac.enabled = require('color-support').hasBasic;
const header = 'txAdmin';
let logHistory = [];

//Helpers
const now = () => { return Math.round(new Date() / 1000) };
const getConCtx = (ctx) => { return (ctx !== null)? header+':'+ctx : header };
const getHistCtx = (ctx) => { return (ctx !== null)? ctx : header };
const toHistory = (type, ctx, msg) =>{
    if(logHistory.length > 4000){
        let sliceMsg = {ts: now(), type: 'ERROR', ctx: 'ConsoleLog', msg: 'The log was sliced to prevent memory exhaustion.'};
        logHistory = logHistory.slice(0,500).concat(sliceMsg, logHistory.slice(-500))
    }
    return logHistory.push({ts: now(), type, ctx, msg});
}
github tabarra / txAdmin / src / components / fxRunner / consoleBuffer.js View on Github external
//Requires
const fs = require('fs');
const ac = require('ansi-colors');
ac.enabled = require('color-support').hasBasic;
const StreamSnitch = require('stream-snitch');
const bytes = require('bytes');
const { dir, log, logOk, logWarn, logError, cleanTerminal } = require('../../extras/console');
const context = 'ConsoleBuffer';

/**
 * FXServer output buffer helper.
 *
 * FIXME: optimize this, we can have only one buffer using offset variables
 * @param {string} logPath
 * @param {int} saveInterval
 */
module.exports = class ConsoleBuffer {
    constructor(logPath, saveInterval) {
        this.hitchStreamProcessor = null;
        this.logFileSize = null;

color-support

A module which will endeavor to guess your terminal's level of color support.

ISC
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis

Popular color-support functions