Security News
Cloudflare Adds Security.txt Setup Wizard
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
The cli-color npm package is a library for adding color and formatting to text in Node.js command line applications. It provides a simple API to style strings that appear in the terminal, making it easier to produce visually distinct and organized output.
Text coloring
This feature allows you to change the color of the text output in the terminal. The example shows how to make text appear in red.
const clc = require('cli-color');
console.log(clc.red('This text is red'));
Text formatting
This feature enables text formatting such as making text bold, underlined, etc. The example demonstrates how to make text bold.
const clc = require('cli-color');
console.log(clc.bold('This text is bold'));
Background coloring
This feature allows you to set the background color of the text. The example shows white text on a blue background.
const clc = require('cli-color');
console.log(clc.bgBlue.white('White text on blue background'));
Chalk is a popular npm package similar to cli-color with a chainable API that allows for easier and more readable syntax. Chalk supports modern terminal features and has a broader color palette compared to cli-color.
Colors is another npm package that adds colors to Node.js console output. It extends String.prototype to add color methods directly to strings, which can be less modular and potentially messier than cli-color's functional approach.
Colors, formatting and other goodies for the console. This package won't mess with built-ins and provides neat way to predefine formatting patterns, see below.
$ npm install cli-color
Usage:
var clc = require('cli-color');
Output colored text:
console.log(clc.red('Text in red'));
Styles can be mixed:
console.log(clc.red.bgWhite.underline('Underlined red text on white background.'));
Styled text can be mixed with unstyled:
console.log(clc.red('red') + ' plain ' + clc.blue('blue'));
Best way is to predefine needed stylings and then use it:
var error = clc.red.bold;
var warn = clc.yellow;
var notice = clc.blue;
console.log(error('Error!'));
console.log(warn('Warning'));
console.log(notice('Notice'));
Supported are all ANSI colors and styles:
Styles will display correctly if font used in your console supports them.
For bright color variants:
Trims ANSI formatted string to plain text
var ansiTrim = require('cli-color/lib/trim');
var plain = ansiTrim(formatted);
Displays throbber on given interval. Interval should be clock.interval object Optionally throbber output can be formatted with given format
var interval = require('clock/lib/interval')
, ansiThrobber = require('cli-color/lib/throbber');
var i = interval(200, true);
// Display throbber while interval is ticking
ansiThrobber(i);
// at any time you can stop/start interval
// When interval is stopped throbber doesn't show
i.stop();
FAQs
Colors, formatting and other tools for the console
The npm package cli-color receives a total of 2,791,653 weekly downloads. As such, cli-color popularity was classified as popular.
We found that cli-color demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.
Security News
ENISA’s 2024 report highlights the EU’s top cybersecurity threats, including rising DDoS attacks, ransomware, supply chain vulnerabilities, and weaponized AI.