This package has been deprecated

Author message:

This project has been renamed. Install using @ialopezg/cli instead.

custom-console-colors
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Custom Console Colors

Custom tools for NodeJS

NPM version NPM downloads Build Status Coverage Status All Contributors
Patreon donate button Open Collective donate button Open Collective donate button

Custom Colors and Formats to be used in NodeJS or in a Terminal console.

Technology Stack

VS Code Shell Git GitHub Node.JS TypeScript JavaScript

Features

  • Compatible with both TypeScript and ES6 (I recommend to use TypeScript)
  • Zero dependencies

Getting started

Requirements

  • npm v6+ or yarn v1.17+
  • NodeJS v8+

Installation

You have two options to install this repository.

  1. By adding the dependency to your package.json file.

    {
      "dependencies": {
        "custom-console-colors": "^0.0.1"
      }
    }
    # Install dependencies
    # NPM
    npm install
    # or Yarn
    yarn
  2. By using a package manager

    # NPM
    npm install --save custom-console-color
    # or Yarn
    yarn add @ialopezg/core

Usage

Usage:

const { Color } = require('custom-console-color')

Colored text

console.log(Color.red('Red color text'));

Mixed styles

console.log(Color.red().bold('Red color text with bold style'))

Styled text with unstyled text

console.log(`${Color.red('Red color')} text with ${Color.bold('unstyled')} text`)

Predefining colors

const error = Color.red;
const log = Color.green;
const notice = Color.blue;
const warn = Color.yellow;

console.log(error('Error!'));
console.log(log('Log!'));
console.log(notice('Notice!'));
console.log(warn('Warning!'));

Another awesome example

const appStarted = (host, port, proxy) => {
  const divider = Color.green('\n-----------------------------------')
  const ip = '127.0.0.1';

  console.log(`Server started! ${Color.green('✓')}`)
  if (proxy) {
    console.log(`Proxy initialized! ${Color.green('✓')}`)
  }

  console.log(`
${Color.bold('Access URLs:')}${divider}
Localhost: ${Color.magenta(`http://${host}:${port}`)}
      LAN: ${Color.magenta(`http://${ip}:${port}`) +
    (proxy ? `\n    Proxy: ${Color.magenta(proxy)}` : '')}${divider}
${Color.blue(`Press ${Color.italic('CTRL-C')} to stop`)}
    `)
};

appStarted('localhost', 3000, '192.168.0.255');

Available Colors and Styles

Styles

  • bold
  • dim
  • italic
  • underline
  • blink
  • inverse
  • hidden
  • strike

Foreground colors

Normal (ANSI) Bright (Extended)
black brightBlack
red brightRed
green brightGreen
yellow brightYellow
blue brightBlue
magenta brightMagenta
cyan brightCyan
white brightWhite

Background colors

Normal (ANSI) Bright (Extended)
bgBlack bgBrightBlack
bgRed bgBrightRed
bgGreen bgBrightGreen
bgYellow bgBrightYellow
bgBlue bgBrightBlue
bgMagenta bgBrightMagenta
bgCyan bgBrightCyan
bgWhite bgBrightWhite

People

Author - Isidro A. Lopez G.

License

CustomConsoleColors is licensed under MIT license.


© Copyright 2019-present - CustomConsoleColors by Isidro A. López G.

Package Sidebar

Install

npm i custom-console-colors

Weekly Downloads

8

Version

0.0.4

License

MIT

Unpacked Size

73 kB

Total Files

34

Last publish

Collaborators

  • ialopezg