Skip to content

Commit 56b91ce

Browse files
43081jmrstork
andauthored
chore: replace chalk with ansis (#6572)
We use ansis elsewhere in the Netlify stack, so we should probably do the same here. ansis is also smaller and faster. Co-authored-by: Mateusz Bocian <[email protected]>
1 parent aaa8edb commit 56b91ce

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"@netlify/zip-it-and-ship-it": "14.1.0",
8080
"@sindresorhus/slugify": "^2.0.0",
8181
"ansi-escapes": "^7.0.0",
82-
"chalk": "^5.0.0",
82+
"ansis": "^4.1.0",
8383
"clean-stack": "^5.0.0",
8484
"execa": "^8.0.0",
8585
"fdir": "^6.0.1",

packages/build/src/log/theme.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
import chalk from 'chalk'
1+
import * as colors from 'ansis'
22

33
/**
4-
* Color theme. Please use this instead of requiring chalk directly,
4+
* Color theme. Please use this instead of requiring ansis directly,
55
* to ensure consistent colors.
66
*/
77
export const THEME = {
88
// Main headers
9-
header: chalk.cyanBright.bold,
9+
header: colors.cyanBright.bold,
1010
// Single lines used as sub-headers
11-
subHeader: chalk.cyan.bold,
11+
subHeader: colors.cyan.bold,
1212
// One of several words that should be highlighted inside a line
13-
highlightWords: chalk.cyan,
13+
highlightWords: colors.cyan,
1414
// Same for errors
15-
errorHeader: chalk.redBright.bold,
16-
errorSubHeader: chalk.red.bold,
17-
errorLine: chalk.redBright,
18-
errorHighlightWords: chalk.redBright.bold,
15+
errorHeader: colors.redBright.bold,
16+
errorSubHeader: colors.red.bold,
17+
errorLine: colors.redBright,
18+
errorHighlightWords: colors.redBright.bold,
1919
// Same for warnings
20-
warningHeader: chalk.yellowBright.bold,
21-
warningSubHeader: chalk.yellow.bold,
22-
warningLine: chalk.yellowBright,
23-
warningHighlightWords: chalk.yellowBright.bold,
20+
warningHeader: colors.yellowBright.bold,
21+
warningSubHeader: colors.yellow.bold,
22+
warningLine: colors.yellowBright,
23+
warningHighlightWords: colors.yellowBright.bold,
2424
// One of several words that should be dimmed inside a line
25-
dimWords: chalk.gray,
25+
dimWords: colors.gray,
2626
// No colors
2727
none: (string) => string,
2828
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import chalk from 'chalk'
1+
import * as colors from 'ansis'
22

33
export const onPreBuild = function () {
4-
console.log(chalk.red('onPreBuild'))
4+
console.log(colors.red('onPreBuild'))
55
}

packages/build/tests/log/tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Fixture, normalizeOutput } from '@netlify/testing'
2+
import * as colors from 'ansis'
23
import test from 'ava'
3-
import chalk from 'chalk'
44
import hasAnsi from 'has-ansi'
55

66
test('Colors in parent process', async (t) => {
@@ -13,7 +13,7 @@ test('Colors in parent process', async (t) => {
1313

1414
test('Colors in child process', async (t) => {
1515
const { output } = await new Fixture('./fixtures/child').withEnv({ FORCE_COLOR: '1' }).runBuildBinary()
16-
t.true(output.includes(chalk.red('onPreBuild')))
16+
t.true(output.includes(colors.red('onPreBuild')))
1717
})
1818

1919
test('Netlify CI', async (t) => {
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import chalk from 'chalk'
1+
import * as colors from 'ansis'
22

33
export const onPreBuild = function () {
4-
throw new Error(chalk.red('ColorTest'))
4+
throw new Error(colors.red('ColorTest'))
55
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import chalk from 'chalk'
1+
import * as colors from 'ansis'
22

33
export const onBuild = function ({
44
utils: {
55
status: { show },
66
},
77
}) {
8-
show({ summary: chalk.red('summary') })
8+
show({ summary: colors.red('summary') })
99
}

0 commit comments

Comments
 (0)