Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/ci/build-types/test_build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import { styleText } from 'node:util';

import { shortSha } from '../../utils.js';
import {
Expand Down Expand Up @@ -119,11 +119,11 @@ export class TestBuild extends Job {
cli.table('Built On', failure.builtOn);
}
if (!reason.includes('\n') && reason.length < 40) {
cli.table('Reason', chalk.red(reason));
cli.table('Reason', styleText('red', reason));
} else {
cli.table('Reason', '');
const lines = reason.split('\n');
cli.log(` ${chalk.red(lines[0])}`);
cli.log(` ${styleText('red', lines[0])}`);
for (let i = 1; i < lines.length; ++i) {
cli.log(` ${lines[i]}`);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/ci/failure_aggregator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chalk from 'chalk';
import { styleText } from 'node:util';

import { getMachineUrl, parsePRFromURL } from '../links.js';
import CIFailureParser from './ci_failure_parser.js';
Expand Down Expand Up @@ -140,7 +140,7 @@ export class FailureAggregator {
cli.table('First CI', `${prs[0].upstream}`);
}
cli.table('Last CI', `${prs[prs.length - 1].upstream}`);
cli.log('\n' + chalk.bold('Example: ') + `${failures[0].url}\n`);
cli.log('\n' + styleText('bold', 'Example: ') + `${failures[0].url}\n`);
const example = failures[0].reason;
cli.log(example.length > 512 ? example.slice(0, 512) + '...' : example);
cli.separator();
Expand Down
12 changes: 6 additions & 6 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import ora from 'ora';
import chalk from 'chalk';
import { styleText } from 'node:util';
import * as inquirer from '@inquirer/prompts';

import { warning, error, info, success } from './figures.js';
Expand All @@ -22,7 +22,7 @@ const QUESTION_TYPE = {
const formatter = new Intl.ListFormat('en', { type: 'disjunction' });

function head(text, length = 11) {
return chalk.bold(text.padEnd(length));
return styleText('bold', text.padEnd(length));
}

export default class CLI {
Expand Down Expand Up @@ -180,9 +180,9 @@ export default class CLI {
const rest = (length - text.length - 2);
const half = sep.repeat(Math.abs(Math.floor(rest / 2)));
if (rest % 2 === 0) {
this.log(`${half} ${chalk.bold(text)} ${half}`);
this.log(`${half} ${styleText('bold', text)} ${half}`);
} else {
this.log(`${half} ${chalk.bold(text)} ${sep}${half}`);
this.log(`${half} ${styleText('bold', text)} ${sep}${half}`);
}
}

Expand All @@ -193,7 +193,7 @@ export default class CLI {

warn(text, options = {}) {
const prefix = options.newline ? this.eolIndent : this.figureIndent;
this.log(prefix + chalk.bold(`${warning} ${text}`));
this.log(prefix + styleText('bold', `${warning} ${text}`));
}

info(text, options = {}) {
Expand All @@ -210,7 +210,7 @@ export default class CLI {
this.log(JSON.stringify(obj.data, null, 2));
}
} else {
this.log(prefix + chalk.bold(`${error} ${obj}`));
this.log(prefix + styleText('bold', `${error} ${obj}`));
}
}

Expand Down
10 changes: 5 additions & 5 deletions lib/figures.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import chalk from 'chalk';
import { figures } from 'listr2';
import { styleText } from 'node:util';

export const warning = chalk.yellow(figures.warning);
export const error = chalk.red(figures.cross);
export const info = chalk.blue(figures.info);
export const success = chalk.green(figures.tick);
export const warning = styleText('yellow', figures.warning);
export const error = styleText('red', figures.cross);
export const info = styleText('blue', figures.info);
export const success = styleText('green', figures.tick);
6 changes: 2 additions & 4 deletions lib/verbosity.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import util from 'node:util';

import chalk from 'chalk';
import { format, styleText } from 'node:util';

const VERBOSITY = {
NONE: 0,
Expand All @@ -25,5 +23,5 @@ export function setVerbosityFromEnv() {

export function debuglog(...args) {
// Prepend a line break in case it's logged while the spinner is running
console.error(chalk.green(util.format('\n[DEBUG]', ...args)));
console.error(styleText('green', format('\n[DEBUG]', ...args)));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to this PR, but as a drive-by, wouldn't we want the line break before the styleText sequence?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally it should be. I'll pick it up in a follow-up PR.

}
15 changes: 0 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"@node-core/caritat": "^1.6.0",
"@pkgjs/nv": "^0.3.0",
"branch-diff": "^3.1.1",
"chalk": "^6.0.0",
"changelog-maker": "^4.4.1",
"cheerio": "^1.0.0",
"core-validate-commit": "^6.0.0",
Expand Down
Loading