Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import supportsColor from 'supports-color';
if (supportsColor) {
console.log('Terminal supports color');
if (supportsColor.hasBasic) {
const level: number = supportsColor.level;
console.log('Terminal has basic color support', level);
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
// $ExpectError
supportsColor.nope;
// $ExpectError
(supportsColor.level: string);
console.log('Terminal has basic color support', level);
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
// $ExpectError
supportsColor.nope;
// $ExpectError
(supportsColor.level: string);
}
import supportsColor from 'supports-color';
if (supportsColor) {
console.log('Terminal supports color');
if (supportsColor.hasBasic) {
const level: number = supportsColor.level;
console.log('Terminal has basic color support', level);
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
// $ExpectError
supportsColor.nope;
// $ExpectError
(supportsColor.level: string);
}
import supportsColor from 'supports-color';
if (supportsColor) {
console.log('Terminal supports color');
if (supportsColor.hasBasic) {
const level: number = supportsColor.level;
console.log('Terminal has basic color support', level);
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
// $ExpectError
supportsColor.nope;
// $ExpectError
(supportsColor.level: string);
}
import supportsColor from 'supports-color';
if (supportsColor) {
console.log('Terminal supports color');
if (supportsColor.hasBasic) {
const level: number = supportsColor.level;
console.log('Terminal has basic color support', level);
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
// $ExpectError
supportsColor.nope;
// $ExpectError
if (supportsColor.hasBasic) {
const level: number = supportsColor.level;
console.log('Terminal has basic color support', level);
}
if (supportsColor.has256) {
console.log('Terminal supports 256 colors');
}
if (supportsColor.has16m) {
console.log('Terminal supports 16 million colors (truecolor)');
}
// $ExpectError
supportsColor.nope;
// $ExpectError
(supportsColor.level: string);
}
const applyOptions = (object, options = {}) => {
if (options.level > 3 || options.level < 0) {
throw new Error('The `level` option should be an integer from 0 to 3');
}
// Detect level if not set manually
const colorLevel = stdoutColor ? stdoutColor.level : 0;
object.level = options.level === undefined ? colorLevel : options.level;
};
String(firstString.raw[i])
);
}
if (template === undefined) {
template = require('./templates');
}
return template(chalk, parts.join(''));
};
Object.defineProperties(Chalk.prototype, styles);
const chalk = Chalk(); // eslint-disable-line new-cap
chalk.supportsColor = stdoutColor;
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
chalk.stderr.supportsColor = stderrColor;
// For TypeScript
chalk.Level = {
None: 0,
Basic: 1,
Ansi256: 2,
TrueColor: 3,
0: 'None',
1: 'Basic',
2: 'Ansi256',
3: 'TrueColor'
};
module.exports = chalk;
import { stdout, stderr } from "supports-color";
if (stdout) {
// Terminal standard output supports color
}
if (stdout.hasBasic) {
// Terminal standard output supports color
}
if (stdout.has256) {
// Terminal standard output supports 256 colors
}
if (stdout.has16m) {
// Terminal standard output supports 16 million colors (truecolor)
}
if (stderr) {
// Terminal standard error supports color
}
if (stderr.hasBasic) {
// Terminal standard error supports color
}
if (stderr.has256) {
// Terminal standard error supports 256 colors
}
if (stderr.has16m) {
// Terminal standard output supports 16 million colors (truecolor)
}
if (stderr) {
// Terminal standard error supports color
}
if (stderr.hasBasic) {
// Terminal standard error supports color
}
if (stderr.has256) {
// Terminal standard error supports 256 colors
}
if (stderr.has16m) {
// Terminal standard error supports 16 million colors (truecolor)
}