How to use the color-support.hasBasic function in color-support

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 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 8 years ago

Package Health Score

65 / 100
Full package analysis

Popular color-support functions