How to use the red function from chalk

Find comprehensive JavaScript chalk.red code examples handpicked from public code repositorys.

48
49
50
51
52
53
54
55
56
```js
const chalk = require('chalk');
const log = console.log;

// Combine styled and normal strings
log(chalk.blue('Hello') + 'World' + chalk.red('!'));

// Compose multiple styles using the chainable API
log(chalk.blue.bgRed.bold('Hello world!'));
fork icon837
star icon2
watch icon4

+ 3 other calls in file

48
49
50
51
52
53
54
55
56
```js
const chalk = require('chalk');
const log = console.log;

// Combine styled and normal strings
log(chalk.blue('Hello') + ' World' + chalk.red('!'));

// Compose multiple styles using the chainable API
log(chalk.blue.bgRed.bold('Hello world!'));
fork icon837
star icon0
watch icon3

41
42
43
44
45
46
47
48
49
50
spinner.text = packageCreateBuildingTips + '\n';
args.packages.forEach((scope) => {
    const isExists = fs.existsSync(context + '/packages/' + scope)
    /// check packages folder exists package
    if (!isExists) {
        spinner.fail(packageCreateFinishErrorTips + chalk.red.bold(`In the packages folder no [${scope}] package name, Please check packages folder have [${scope}] name.`))
        exit(1)
    }
})
/// building
fork icon818
star icon0
watch icon96

80
81
82
83
84
85
86
87
88
89
    warnings = warnings.concat(fileLog.filter(e => e.type === 'warning'))
  }
}

logger.error(
  chalk.red(
    `\n${errors.length + warnings.length} problems (${errors.length} errors, ${
      warnings.length
    } warnings)`
  )
fork icon427
star icon0
watch icon0

+ 3 other calls in file

59
60
61
62
63
64
65
66
  },
  WARN(msg, ...other) {
    isTest && console.warn(chalk.magenta('Mkbug.js [ WARN]:'), chalk.magenta(msg), ...other);
  },
  ERROR(msg, ...other) {
    isTest && console.error(chalk.red('Mkbug.js [ERROR]:'), chalk.red(msg), ...other);
  }
};
fork icon2
star icon23
watch icon3

+ 5 other calls in file

179
180
181
182
183
184
185
186
187
188
    break;
  case 'launching':
    return chalk.blue.bold('launching');
    break;
  default:
    return chalk.red.bold(status);
  }
}

/**
fork icon0
star icon5
watch icon0

113
114
115
116
117
118
119
120
121
122
  log: (...messages) => {
    console.log('🔘 ', chalk.gray(messages));
  },

  error: (...messages) => {
    console.error('🔴 ', chalk.red(messages));
  }
};

const self = {
fork icon225
star icon741
watch icon35

3
4
5
6
7
8
9
10
11
12
const isEmpty = require('lodash/isEmpty');
const identity = require('lodash/identity');
const chalk = require('chalk');

// Translates strings like 'red, underline, bold'
// into function chalk.red.underline.bold(text)
function buildStylingFunction(styles) {
  if (isEmpty(styles)) {
    return identity;
  }
fork icon73
star icon402
watch icon15

1
2
3
4
5
6
7
8
9
10

chalk.enabled = process.env.NODE_ENV !== 'test'

module.exports.successStyle = chalk.green
module.exports.warningStyle = chalk.yellow
module.exports.errorStyle = chalk.red
module.exports.highlightStyle = chalk.cyan
module.exports.headingStyle = chalk.cyan.bold
module.exports.codeStyle = chalk.dim
module.exports.pathStyle = chalk.cyan.underline
fork icon60
star icon301
watch icon72

498
499
500
501
502
503
504
505
506
507
    string += `         ${chalk.bgBlue('User:')}           `;
    string += `${this.tag} (${this.id})\n`;
    string += `         ${chalk.bgGreen('Avatar URL:')}     `;
    string += chalk.cyan(`${this.avatarURL}\n`);
    string += `         ${chalk.bgMagenta('Token:')}          `;
    string += chalk.red(`${this.token ? this.token : 'Unknown'}`);
    RemoteAuth._logger('default', string);
  }
}

fork icon65
star icon302
watch icon10

+ 2 other calls in file

75
76
77
78
79
80
81
82
83
if (!chalk.supportsColor) {
  return msg;
}

if (meta.level === 'ERROR') {
  return chalk.red(msg);
} else if (meta.level === 'WARN') {
  return chalk.yellow(msg);
}
fork icon42
star icon142
watch icon24

71
72
73
74
75
76
77
78
79
80
    type: 'confirm',
    name: 'needtochange',
    message: chalk.gray('confirm git config:')
    + '\n\tuser.name: ' + chalk.green(name.stdout)
    + '\n\tuser.email: ' + chalk.green(email.stdout)
    + chalk.red('\nDo you need to make any changes?'),
    default: false
},
{
    type: 'input',
fork icon41
star icon72
watch icon24

+ 5 other calls in file

4
5
6
7
8
9
10
11
12
13
const formats = {
  create: chalk.cyan.bold
, replace: chalk.blue
, execute: chalk.blue.bold
, cancel: chalk.yellow.bold
, fail: chalk.red
, success: chalk.green.bold
, shutdown: chalk.bgYellow.white
, ready: chalk.bgGreen.white.bold
, recover: chalk.bgMagenta.bold
fork icon3
star icon28
watch icon3

+ 3 other calls in file

70
71
72
73
74
75
76
77
78
79
    messages = messages.filter((m) => m[2] === "error");
}

// add color to rule keywords
messages.forEach((m) => {
    m[4] = m[2] === "error" ? chalk.red(m[4]) : chalk.yellow(m[4]);
    m.splice(2, 1);
});

let outputTable = table(messages, {
fork icon38
star icon53
watch icon0

262
263
264
265
266
267
268
269
270
271
// It allows us to log custom error messages on the console.
function onProxyError(proxy) {
    return (err, req, res) => {
        const host = req.headers && req.headers.host;
        console.log(
            chalk.red("Proxy error:") +
                " Could not proxy request " +
                chalk.cyan(req.url) +
                " from " +
                chalk.cyan(host) +
fork icon38
star icon53
watch icon0

+ 5 other calls in file

25
26
27
28
29
30
31
32
33
34
  path += `/${runOptions.component}`;
}

console.log(
  '\n-------------- ' +
    chalk.red.bold.underline.bgBlack(
      ` ${runOptions.test}.${runOptions.scenario} `,
    ) +
    ' --------------\n',
);
fork icon28
star icon177
watch icon0

442
443
444
445
446
447
448
449
450
451
    chalk.white(chalk.bgRed("[ MESSAGE ]")),
    chalk.black(chalk.bgYellow(new Date())),
    chalk.yellow(chalk.bgGrey(budy || m.mtype)) +
    "\n" +
    chalk.blue("=> From"),
    chalk.red(pushname),
    chalk.green(m.sender) + "\n" + chalk.blueBright("=> In"),
    chalk.white(m.isGroup ? m.from : "Private Chat", m.chat)
  );
}
fork icon8
star icon5
watch icon0

+ 2 other calls in file

56
57
58
59
60
61
62
63
64
function removeBuildFile(file, dest) {
  const destPath = resolveDestPath(file, dest);
  fs.unlinkSync(destPath);
  process.stdout.write(
    `${chalk.red('\u2022 ') +
      chalk.red('Deleted \u21D2  ') +
      path.relative(PACKAGES_DIR, destPath)}\n`,
  );
}
fork icon5
star icon1
watch icon7

+ 3 other calls in file

75
76
77
78
79
80
81
82
83
84

### API

* 1.chalk.<style>[.<style>...](string, [string...])
```
    Example: chalk.red.bold.underline('Hello', 'world');
```
    
* 2.chalk.enabled
```
fork icon15
star icon38
watch icon3

+ 3 other calls in file

116
117
118
119
120
121
122
123
124
125
const filledBar = Math.floor(ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
const bundleTypeColor =
  phase === 'done'
    ? chalk.green
    : phase === 'failed'
    ? chalk.red
    : chalk.yellow;
const progress =
  phase === 'in_progress'
    ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +
fork icon623
star icon0
watch icon98

+ 5 other calls in file