How to use the ansi-colors.bgRed function in ansi-colors

To help you get started, we’ve selected a few ansi-colors 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 pnp / pnpjs / tools / buildsystem / src / builder.ts View on Github external
export async function builder(version: string, config: BuildSchema): Promise {

    // log we are starting the shared build tasks
    log(`${colors.bgBlue(" ")} Beginning shared build tasks.`);

    try {

        // run global tasks
        await Promise.all(config.tasks.map(task => task(version, config)));

        log(`${colors.bgGreen(" ")} Finished shared build tasks.`);

    } catch (e) {

        log(`${colors.bgRed(" ")} ${colors.bold(colors.red(`Error in shared build tasks.`))}.`);
        log(`${colors.bgRed(" ")} ${colors.bold(colors.red("Error:"))} ${colors.bold(colors.white(typeof e === "string" ? e : JSON.stringify(e)))}`);
        throw e;
    }

    // run the per package tasks
    return config.packages.reduce((pipe: Promise, pkg) => {

        if (typeof pkg === "string") {
            pkg = { name: pkg };
        }

        // gate the package names so folks don't try and run code down the line
        if (!/^[\w-]+$/i.test(pkg.name)) {
            throw Error(`Bad package name "${pkg.name}".`);
        }

        const projectFolder = path.join(config.packageRoot, pkg.name);
github AndiDittrich / gulp-prettyerror / gulp-prettyerror.js View on Github external
// make sure there is codeFrame in the error object
            if (codeFrame){
                // add indentation
                const msg = codeFrame.replace(/\n/g, '\n    ');
                
                _logger.error('|- ' + _colors.bgRed('>>>'));
                _logger.error('|\n    ' + msg + '\n           |');
                _logger.error('|- ' + _colors.bgRed('<<<'));

            // stacktrace available ?
            }else if (cause.stack){
                // add indentation
                const stacktrace = cause.stack.replace(/^(\s*)/gm, '           | ');
                
                _logger.error('|- ' + _colors.bgRed('>>>'));
                _logger.error('|\n' + stacktrace + '\n           |');
                _logger.error('|- ' + _colors.bgRed('<<<'));
            }
            
            // make sure the process is finished
            this.emit('end');
        });
    }
github ionic-team / stencil / src / sys / node_next / node-logger.ts View on Github external
} else if (rightSideChars > 1) {
        // larger on right side
        errorLine = errorLine.substr(0, errorLine.length - 1);
        rightSideChars--;

      } else {
        break;
      }
    }

    const lineChars: string[] = [];
    const lineLength = Math.max(errorLine.length, errorCharStart + errorLength);
    for (var i = 0; i < lineLength; i++) {
      var chr = errorLine.charAt(i);
      if (i >= errorCharStart && i < errorCharStart + errorLength) {
        chr = color.bgRed(chr === '' ? ' ' : chr);
      }
      lineChars.push(chr);
    }

    return lineChars.join('');
  }
github ionic-team / stencil / src / sys / node / node-logger.ts View on Github external
} else if (rightSideChars > 1) {
        // larger on right side
        errorLine = errorLine.substr(0, errorLine.length - 1);
        rightSideChars--;

      } else {
        break;
      }
    }

    const lineChars: string[] = [];
    const lineLength = Math.max(errorLine.length, errorCharStart + errorLength);
    for (var i = 0; i < lineLength; i++) {
      var chr = errorLine.charAt(i);
      if (i >= errorCharStart && i < errorCharStart + errorLength) {
        chr = color.bgRed(chr === '' ? ' ' : chr);
      }
      lineChars.push(chr);
    }

    return lineChars.join('');
  }
github NewFuture / miniprogram-build / src / config.js View on Github external
function loadConfig(configFile) {
    if (CACHE[configFile]) {
        return CACHE[configFile];
    }
    if (configFile) {
        if (!fs.existsSync(configFile)) {
            log.error(TITLE, colors.red.underline(configFile), colors.bgRed('does not exist'));
            throw new Error(configFile + 'does not exist');
        }
    }
    try {
        var json = fs.readFileSync(configFile, 'utf-8');
        var config = json5.parse(json);
        // @ts-ignore
        const version = require('../package.json').version;
        log.info(TITLE, colors.cyan.italic.dim(`v${version}`), colors.gray.dim('load config'), colors.gray.bold.underline(configFile))
        const allowedKeys = Object.keys(exports.default);

        config = Object.keys(config)
            .filter(key => allowedKeys.indexOf(key) >= 0)
            .reduce((obj, key) => { obj[key] = config[key]; return obj }, {})
        CACHE[configFile] = config;
        return config;
github ivogabe / gulp-typescript / release / reporter.js View on Github external
error: (error, typescript) => {
            console.log('[' + colors.gray('gulp-typescript') + '] '
                + colors.bgRed(error.diagnostic.code + '')
                + ' ' + colors.red(typescript.flattenDiagnosticMessageText(error.diagnostic.messageText, '\n')));
            if (error.tsFile) {
                console.log('> ' + colors.gray('file: ') + (fullFilename ? error.fullFilename : error.relativeFilename) + colors.gray(':'));
                const lines = error.tsFile.text.split(/(?:\r\n|\r|\n)/);
                const logLine = (lineIndex, errorStart, errorEnd) => {
                    const line = lines[lineIndex];
                    if (errorEnd === undefined)
                        errorEnd = line.length;
                    console.log('> ' + colors.gray('[' + (lineIndex + 1) + '] ')
                        + line.substring(0, errorStart)
                        + colors.red(line.substring(errorStart, errorEnd))
                        + line.substring(errorEnd));
                };
                for (let i = error.startPosition.line; i <= error.endPosition.line; i++) {
                    logLine(i, i === error.startPosition.line ? error.startPosition.character : 0, i === error.endPosition.line ? error.endPosition.character : undefined);
                }
github NewFuture / miniprogram-build / src / log / error.js View on Github external
function logError(err) {
        const skip = process.env.SKIP_ERROR;
        log.error(
            color(TITLE),
            colors.bold.redBright("[" + colors.symbols.cross + "]"),
            colors.red(err.name),
            "\n" +
            colors.bgRed(err.message),
            "\n" +
            //@ts-ignore
            colors.red.underline(err.fileName || err.relativePath),
            "\n" + (skip ? '' : err.stack ? (err.stack + '\n' + err) : JSON.stringify(err, null, 2).substring(0, 2000))
        );
        if (skip) {
            if (this && this.emit) {
                return this.emit("end", err);
            }
        } else {
            process.exit(1);
        }
    };
    return logError
github pnp / pnpjs / tools / buildsystem / src / builder.ts View on Github external
}).catch(e => {

            log(`${colors.bgRed(" ")} ${colors.bold(colors.red(`Error building `))} ${colors.bold(colors.cyan(buildContext.projectFile))}.`);
            log(`${colors.bgRed(" ")} ${colors.bold(colors.red("Error:"))} ${colors.bold(colors.white(typeof e === "string" ? e : JSON.stringify(e)))}`);
        });

ansi-colors

Easily add ANSI colors to your text and symbols in the terminal. A faster drop-in replacement for chalk, kleur and turbocolor (without the dependencies and rendering bugs).

MIT
Latest version published 2 years ago

Package Health Score

74 / 100
Full package analysis