How to use the bold function from chalk

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

chalk.bold is a function in the chalk library that applies bold style to the input text.

75
76
77
78
79
80
81
82
83
84
)

if (args.types && pkg.types) {
  console.log()
  console.log(
    chalk.bold(chalk.yellow(`Rolling up type definitions for ${target}...`))
  )

  // build types
  const { Extractor, ExtractorConfig } = require('@microsoft/api-extractor')
fork icon0
star icon288
watch icon24

+ 32 other calls in file

36
37
38
39
40
41
42
43
44
45
log(
  'To date:       ',
  chalk.bold(chalk.yellow(getFormattedDate(adjustedEndDate, dateTimeFormatOptions)))
);
if (timeframe !== 'tick') {
  log('Price type:    ', chalk.bold(chalk.yellow(priceType)));
}
log('Volumes:       ', chalk.bold(chalk.yellow(volumes)));
log('UTC Offset:    ', chalk.bold(chalk.yellow(utcOffset)));
log('Include flats: ', chalk.bold(chalk.yellow(!ignoreFlats)));
fork icon42
star icon184
watch icon8

+ 17 other calls in file

How does chalk.bold work?

chalk.bold is a method of the chalk library in Node.js that returns a new function to style text with bold font weight in the terminal. It works by applying ANSI escape codes to the text to change the font weight.

58
59
60
61
62
63
64
65
66
67
log(chalk.hex('#DEADED').bold('Bold gray!'));
Easily define your own themes:

const chalk = require('chalk');

const error = chalk.bold.red;
const warning = chalk.keyword('orange');

console.log(error('Error!'));
console.log(warning('Warning!'));
fork icon15
star icon38
watch icon3

27
28
29
30
31
32
33
34
35

    return line;
},

stackLine: function (name, location, isLast) {
    var line = '   at ' + chalk.bold(name) + ' (' + chalk.grey.underline(location) + ')';

    if (!isLast)
        line += '\n';
fork icon11
star icon156
watch icon8

Ai Example

1
2
3
const chalk = require("chalk");

console.log(chalk.bold("This text will be displayed in bold"));

When you run this script, the text "This text will be displayed in bold" will be printed to the console in bold. The chalk.bold method is used to add the bold formatting to the text.

58
59
60
61
62
63
64
65
66
const filePath = getPackage(packagesDir, customPackage);
if (filePath) {
  startPackage(packagesDir, filePath);
} else {
  process.stdout.write(
    chalk.bold.inverse(`package ${customPackage} not exists\n`),
  );
}
process.stdout.write('\n');
fork icon1
star icon6
watch icon8

169
170
171
172
173
174
175
176
177
178
var port = l.pm2_env.port;
var key = l.pm2_env.name || p.basename(l.pm2_env.pm_exec_path.script);

if (l.pm2_env.pmx_module == true) {
  obj[key] = [
    chalk.bold(l.pm2_env.axm_options.module_version || 'N/A'),
    l.pid,
    colorStatus(status),
    l.pm2_env.restart_time ? l.pm2_env.restart_time : 0,
    l.monit.cpu + '%',
fork icon0
star icon2
watch icon11

+ 12 other calls in file

11
12
13
14
15
16
17
18
19
20
  divider = Array(process.stdout.columns || 32).join('-')
}
setLineLength()
process.stdout.on('resize', setLineLength)

const progressStyle = chalk.bold.inverse
const statusStyle = chalk.green.italic
const warningStyle = chalk.black.bold.bgYellow

const cmdDirStyle = chalk.blue
fork icon734
star icon0
watch icon109

124
125
126
127
128
129
130
131
132
133
  phase === 'in_progress'
    ? chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +
      chalk.bgWhite.white(
        LIGHT_BLOCK_CHAR.repeat(MAX_PROGRESS_BAR_CHAR_WIDTH - filledBar),
      ) +
      chalk.bold(` ${(100 * ratio).toFixed(1)}% `) +
      chalk.dim(`(${transformedFileCount}/${totalFileCount})`)
    : '';

return (
fork icon623
star icon0
watch icon98

+ 7 other calls in file

91
92
93
94
95
96
97
98
99
100
  [label, chalk.dim],
'Token': libraryToken.is_valid ?
  Token :
  [Token, chalk.dim],
'Valid': libraryToken.is_valid ?
  ['✔', chalk.bold.green] :
  ['✖', chalk.bold.red],
'Created': libraryToken.is_valid ?
  libraryToken.created_at :
  [libraryToken.created_at, chalk.dim],
fork icon194
star icon0
watch icon79

+ 3 other calls in file

232
233
234
235
236
237
238
239
240
241
以下是 `chalk` 示例,`Error` 与 `Warning` 信息用不同的颜色表示

``` js
const chalk = require('chalk')
 
const error = chalk.bold.red
const warning = chalk.keyword('orange')
 
console.log(error('Error!'))
console.log(warning('Warning!'))
fork icon197
star icon0
watch icon57

+ 7 other calls in file

36
37
38
39
40
41
42
43
44
        console.log(chalk.dim(this.showLogs ? 'Showing Logs...' : 'Hiding logs.'));
}

intro(instances) {
        console.log('');
        console.log(chalk.bgBlack.white(' ❯❯❯_ '), chalk.bold('Kju v' + version));
        console.log(chalk.dim(`Loading ${instances} instances...`));
        console.log('');
}
fork icon15
star icon70
watch icon9

53
54
55
56
57
58
59
60
61
62

let line = message.line || 0;
if (message.column) {
    line += ":" + message.column;
}
let position = chalk.bold("Line " + line + ":");
return [
    "",
    position,
    messageType,
fork icon38
star icon53
watch icon0

30
31
32
33
34
35
36
37
38
39
    });
const prettyPrintUrl = (hostname) =>
    url.format({
        protocol,
        hostname,
        port: chalk.bold(port),
        pathname,
    });

const isUnspecifiedHost = host === "0.0.0.0" || host === "::";
fork icon38
star icon53
watch icon0

59
60
61
62
63
64
65
66
67
68

// DEFINING THEMES FROM CHALK DOCS ONLY.
let redBold = chalk.bold.red;
log(redBold("home..."));

let redBoldUnderline = chalk.bold.underline.red;
log(redBoldUnderline("testing.."));

let redItalics = chalk.red.italic;
log(redItalics("home..."));
fork icon3
star icon3
watch icon0

+ 3 other calls in file

148
149
150
151
152
153
154
155
156
157
    lines.push('');
    console.log(lines.join('\n'))
}

drawStep(step) {
    let line = this.indent + chalk.bold(this.statusIcons[step.testStepResult.status]) + ' ' + step.stepText;
    line += ` ${chalk.gray(step.location)}`;
    if (this.showLogs) {
        for (const log of step.logs) {
            line += `\n${this.indent}${log.body}`;
fork icon0
star icon4
watch icon0

1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
//console.log({collectionName});
let airtableURLs = ( await Collections.findOne({name: collectionName}).lean() ).airtable;

if (airtableURLs == undefined) {

    // //console.log( chalk.bold.bgYellow.black( "DATA IS NOT CONNECTED WITH AIRTABLE" ) ); 

    return { msg: "Data not connected to Airtable" };

}
fork icon0
star icon2
watch icon1

+ 15 other calls in file

20
21
22
23
24
25
26
27
28
29
30
31
};


const getUpdateMessage = (newVersion, currentVersion) => {
  const currentVersionLog = chalk.dim(currentVersion);
  const newVersionLog = chalk.green(newVersion);
  const releaseLink = chalk.bold('https://github.com/strapi/strapi/releases');


  return `
A new version of Strapi is available ${currentVersionLog} → ${newVersionLog}
Check out the new releases at: ${releaseLink}
fork icon0
star icon1
watch icon0

26
27
28
29
30
31
32
33
34
35
36
37
38
39




server.listen(server_port);


server.on("listening", async() =>{
    console.log(chalk.bold.cyanBright("[APP] ") + chalk.bold.whiteBright(`Localhost : http://${config.app.address}:${config.app.port}`));
    console.log(chalk.bold.cyanBright("[APP] ") + chalk.bold.whiteBright(`Listening on port : `) + chalk.bold.yellowBright(String(config.app.port)));
});


server.on("error", onError);
fork icon0
star icon1
watch icon0

+ 3 other calls in file

1
2
3
4
5
6
7
8
9
10
11
const mysql = require('../helpers/db')
const _ = require("lodash")
const bcrypt = require('bcrypt')
const { now } = require('lodash')
const chalk = require('chalk');
const connected = chalk.bold.cyan;
const { shopID, discountAmount, gstAmount, generateUniqueBarcode, doesExistProduct, generateBarcode } = require('../helpers/helper_function')
const { Idd } = require('../helpers/helper_function')


var multer = require("multer")
fork icon1
star icon0
watch icon1

+ 7 other calls in file

33
34
35
36
37
38
39
40
41
42
  }
  return parseFloat(value, 10) < border ? chalk.green(value) : chalk.red(value);
}

const paramsConfig = {
  'Ticker': (m) => chalk.bold(m.ticker),
  'Sector': (m) => m.assetProfile?.sector ?? '-',
  'Audit Risk': (m) => greenRed(m.assetProfile?.auditRisk, 5),
  'Overall Risk': (m) => greenRed(m.assetProfile?.overallRisk, 5),
  'Currency': (m) => m.financialData?.financialCurrency ?? '-',
fork icon0
star icon4
watch icon2