Skip to content

Commit 060d587

Browse files
committedMay 26, 2023
deps: chalk@5.2.0, npm-audit-report@5.0.0
1 parent 9e7f5ac commit 060d587

37 files changed

+1076
-944
lines changed
 

‎DEPENDENCIES.md

-5
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ graph LR;
288288
cacache-->ssri;
289289
cacache-->tar;
290290
cacache-->unique-filename;
291-
chalk-->ansi-styles;
292-
chalk-->supports-color;
293291
cidr-regex-->ip-regex;
294292
cli-columns-->string-width;
295293
cli-columns-->strip-ansi;
@@ -583,7 +581,6 @@ graph LR;
583581
npm-->validate-npm-package-name;
584582
npm-->which;
585583
npm-->write-file-atomic;
586-
npm-audit-report-->chalk;
587584
npm-bundled-->npm-normalize-package-bin;
588585
npm-install-checks-->semver;
589586
npm-package-arg-->hosted-git-info;
@@ -607,7 +604,6 @@ graph LR;
607604
npmcli-arborist-->benchmark;
608605
npmcli-arborist-->bin-links;
609606
npmcli-arborist-->cacache;
610-
npmcli-arborist-->chalk;
611607
npmcli-arborist-->common-ancestor-path;
612608
npmcli-arborist-->hosted-git-info;
613609
npmcli-arborist-->isaacs-string-locale-compare["@isaacs/string-locale-compare"];
@@ -787,7 +783,6 @@ graph LR;
787783
string-width-->strip-ansi;
788784
string_decoder-->safe-buffer;
789785
strip-ansi-->ansi-regex;
790-
supports-color-->has-flag;
791786
tar-->chownr;
792787
tar-->fs-minipass;
793788
tar-->minipass;

‎lib/commands/audit.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const auditReport = require('npm-audit-report')
1+
const npmAuditReport = require('npm-audit-report')
22
const fetch = require('npm-registry-fetch')
33
const localeCompare = require('@isaacs/string-locale-compare')('en')
44
const npa = require('npm-package-arg')
@@ -457,7 +457,10 @@ class Audit extends ArboristWorkspaceCmd {
457457
} else {
458458
// will throw if there's an error, because this is an audit command
459459
auditError(this.npm, arb.auditReport)
460-
const result = auditReport(arb.auditReport, opts)
460+
const result = npmAuditReport(arb.auditReport, {
461+
...opts,
462+
chalk: this.npm.chalk,
463+
})
461464
process.exitCode = process.exitCode || result.exitCode
462465
this.npm.output(result.report)
463466
}

‎lib/commands/exec.js

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class Exec extends BaseCommand {
5454
localBin,
5555
globalBin,
5656
globalDir,
57+
chalk,
5758
} = this.npm
5859
const output = this.npm.output.bind(this.npm)
5960
const scriptShell = this.npm.config.get('script-shell') || undefined
@@ -83,6 +84,7 @@ class Exec extends BaseCommand {
8384
globalBin,
8485
globalPath,
8586
output,
87+
chalk,
8688
packages,
8789
path: localPrefix,
8890
runPath,

‎lib/commands/init.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ class Init extends BaseCommand {
119119
}
120120

121121
const newArgs = [packageName, ...otherArgs]
122-
const { color } = this.npm.flatOptions
123122
const {
124123
flatOptions,
125124
localBin,
126125
globalBin,
126+
chalk,
127127
} = this.npm
128128
const output = this.npm.output.bind(this.npm)
129129
const runPath = path
@@ -133,10 +133,10 @@ class Init extends BaseCommand {
133133
await libexec({
134134
...flatOptions,
135135
args: newArgs,
136-
color,
137136
localBin,
138137
globalBin,
139138
output,
139+
chalk,
140140
path,
141141
runPath,
142142
scriptShell,

‎lib/npm.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const { resolve, dirname, join } = require('path')
22
const Config = require('@npmcli/config')
3-
const chalk = require('chalk')
43
const which = require('which')
54
const fs = require('fs/promises')
65

@@ -42,12 +41,13 @@ class Npm {
4241
#loadPromise = null
4342
#title = 'npm'
4443
#argvClean = []
45-
#chalk = null
46-
#logChalk = null
47-
#noColorChalk = new chalk.Instance({ level: 0 })
4844
#npmRoot = null
4945
#warnedNonDashArg = false
5046

47+
#chalk = null
48+
#logChalk = null
49+
#noColorChalk = null
50+
5151
#outputBuffer = []
5252
#logFile = new LogFile()
5353
#display = new Display()
@@ -194,6 +194,13 @@ class Npm {
194194

195195
await this.time('npm:load:configload', () => this.config.load())
196196

197+
const { Chalk, supportsColor, supportsColorStderr } = await import('chalk')
198+
this.#noColorChalk = new Chalk({ level: 0 })
199+
this.#chalk = this.color ? new Chalk({ level: supportsColor.level })
200+
: this.#noColorChalk
201+
this.#logChalk = this.logColor ? new Chalk({ level: supportsColorStderr.level })
202+
: this.#noColorChalk
203+
197204
// mkdir this separately since the logs dir can be set to
198205
// a different location. if this fails, then we don't have
199206
// a cache dir, but we don't want to fail immediately since
@@ -301,20 +308,10 @@ class Npm {
301308
}
302309

303310
get chalk () {
304-
if (!this.#chalk) {
305-
this.#chalk = new chalk.Instance({
306-
level: this.color ? chalk.level : 0,
307-
})
308-
}
309311
return this.#chalk
310312
}
311313

312314
get logChalk () {
313-
if (!this.#logChalk) {
314-
this.#logChalk = new chalk.Instance({
315-
level: this.logColor ? chalk.stderr.level : 0,
316-
})
317-
}
318315
return this.#logChalk
319316
}
320317

‎lib/utils/explain-eresolve.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const explain = (expl, chalk, depth) => {
4444
}
4545

4646
// generate a full verbose report and tell the user how to fix it
47-
const report = (expl, chalk, noColor) => {
47+
const report = (expl, chalk, noColorChalk) => {
4848
const flags = [
4949
expl.strictPeerDeps ? '--no-strict-peer-deps' : '',
5050
'--force',
@@ -61,7 +61,7 @@ to accept an incorrect (and potentially broken) dependency resolution.`
6161

6262
return {
6363
explanation: `${explain(expl, chalk, 4)}\n\n${fix}`,
64-
file: `# npm resolution error report\n\n${explain(expl, noColor, Infinity)}\n\n${fix}`,
64+
file: `# npm resolution error report\n\n${explain(expl, noColorChalk, Infinity)}\n\n${fix}`,
6565
}
6666
}
6767

‎lib/utils/reify-output.js

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const getAuditReport = (npm, report) => {
116116
reporter,
117117
...npm.flatOptions,
118118
auditLevel,
119+
chalk: npm.chalk,
119120
})
120121
if (npm.command === 'audit') {
121122
process.exitCode = process.exitCode || res.exitCode

‎node_modules/.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
!/gauge
112112
!/glob
113113
!/graceful-fs
114-
!/has-flag
115114
!/has-unicode
116115
!/has
117116
!/hosted-git-info
@@ -284,7 +283,6 @@
284283
!/string-width
285284
!/strip-ansi-cjs
286285
!/strip-ansi
287-
!/supports-color
288286
!/tar
289287
!/tar/node_modules/
290288
/tar/node_modules/*

‎node_modules/chalk/license

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
3+
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
66

‎node_modules/chalk/package.json

+36-23
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
{
22
"name": "chalk",
3-
"version": "4.1.2",
3+
"version": "5.2.0",
44
"description": "Terminal string styling done right",
55
"license": "MIT",
66
"repository": "chalk/chalk",
77
"funding": "https://github.com/chalk/chalk?sponsor=1",
8-
"main": "source",
8+
"type": "module",
9+
"main": "./source/index.js",
10+
"exports": "./source/index.js",
11+
"imports": {
12+
"#ansi-styles": "./source/vendor/ansi-styles/index.js",
13+
"#supports-color": {
14+
"node": "./source/vendor/supports-color/index.js",
15+
"default": "./source/vendor/supports-color/browser.js"
16+
}
17+
},
18+
"types": "./source/index.d.ts",
919
"engines": {
10-
"node": ">=10"
20+
"node": "^12.17.0 || ^14.13 || >=16.0.0"
1121
},
1222
"scripts": {
13-
"test": "xo && nyc ava && tsd",
23+
"test": "xo && c8 ava && tsd",
1424
"bench": "matcha benchmark.js"
1525
},
1626
"files": [
1727
"source",
18-
"index.d.ts"
28+
"!source/index.test-d.ts"
1929
],
2030
"keywords": [
2131
"color",
@@ -25,7 +35,6 @@
2535
"console",
2636
"cli",
2737
"string",
28-
"str",
2938
"ansi",
3039
"style",
3140
"styles",
@@ -40,29 +49,33 @@
4049
"command-line",
4150
"text"
4251
],
43-
"dependencies": {
44-
"ansi-styles": "^4.1.0",
45-
"supports-color": "^7.1.0"
46-
},
4752
"devDependencies": {
48-
"ava": "^2.4.0",
49-
"coveralls": "^3.0.7",
50-
"execa": "^4.0.0",
51-
"import-fresh": "^3.1.0",
53+
"@types/node": "^16.11.10",
54+
"ava": "^3.15.0",
55+
"c8": "^7.10.0",
56+
"color-convert": "^2.0.1",
57+
"execa": "^6.0.0",
58+
"log-update": "^5.0.0",
5259
"matcha": "^0.7.0",
53-
"nyc": "^15.0.0",
54-
"resolve-from": "^5.0.0",
55-
"tsd": "^0.7.4",
56-
"xo": "^0.28.2"
60+
"tsd": "^0.19.0",
61+
"xo": "^0.53.0",
62+
"yoctodelay": "^2.0.0"
5763
},
5864
"xo": {
5965
"rules": {
6066
"unicorn/prefer-string-slice": "off",
61-
"unicorn/prefer-includes": "off",
62-
"@typescript-eslint/member-ordering": "off",
63-
"no-redeclare": "off",
64-
"unicorn/string-content": "off",
65-
"unicorn/better-regex": "off"
67+
"@typescript-eslint/consistent-type-imports": "off",
68+
"@typescript-eslint/consistent-type-exports": "off",
69+
"@typescript-eslint/consistent-type-definitions": "off"
6670
}
71+
},
72+
"c8": {
73+
"reporter": [
74+
"text",
75+
"lcov"
76+
],
77+
"exclude": [
78+
"source/vendor"
79+
]
6780
}
6881
}

‎node_modules/chalk/source/index.js

+80-84
Original file line numberDiff line numberDiff line change

‎node_modules/chalk/source/templates.js

-134
This file was deleted.

‎node_modules/chalk/source/util.js

-39
This file was deleted.

‎node_modules/chalk/source/utilities.js

+33
Original file line numberDiff line numberDiff line change

‎node_modules/chalk/source/vendor/ansi-styles/index.js

+223
Original file line numberDiff line numberDiff line change

‎node_modules/chalk/source/vendor/supports-color/browser.js

+30
Original file line numberDiff line numberDiff line change

‎node_modules/chalk/source/vendor/supports-color/index.js

+181
Original file line numberDiff line numberDiff line change

‎node_modules/has-flag/index.js

-8
This file was deleted.

‎node_modules/has-flag/license

-9
This file was deleted.

‎node_modules/has-flag/package.json

-46
This file was deleted.

‎node_modules/npm-audit-report/lib/colors.js

+7-9
Original file line numberDiff line numberDiff line change

‎node_modules/npm-audit-report/lib/index.js

+2-2
Original file line numberDiff line numberDiff line change

‎node_modules/npm-audit-report/lib/reporters/detail.js

+5-5
Original file line numberDiff line numberDiff line change

‎node_modules/npm-audit-report/lib/reporters/install.js

+2-2
Original file line numberDiff line numberDiff line change

‎node_modules/npm-audit-report/package.json

+5-8
Original file line numberDiff line numberDiff line change

‎node_modules/supports-color/browser.js

-5
This file was deleted.

‎node_modules/supports-color/index.js

-135
This file was deleted.

‎node_modules/supports-color/license

-9
This file was deleted.

‎node_modules/supports-color/package.json

-53
This file was deleted.

‎package-lock.json

+109-20
Original file line numberDiff line numberDiff line change

‎package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"abbrev": "^2.0.0",
6363
"archy": "~1.0.0",
6464
"cacache": "^17.1.2",
65-
"chalk": "^4.1.2",
65+
"chalk": "^5.2.0",
6666
"ci-info": "^3.8.0",
6767
"cli-columns": "^4.0.0",
6868
"cli-table3": "^0.6.3",
@@ -94,7 +94,7 @@
9494
"ms": "^2.1.2",
9595
"node-gyp": "^9.3.1",
9696
"nopt": "^7.1.0",
97-
"npm-audit-report": "^4.0.0",
97+
"npm-audit-report": "^5.0.0",
9898
"npm-install-checks": "^6.1.1",
9999
"npm-package-arg": "^10.1.0",
100100
"npm-pick-manifest": "^8.0.1",

‎tap-snapshots/test/lib/utils/explain-dep.js.test.cjs

+38-38
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,45 @@
55
* Make sure to inspect the output below. Do not ignore changes!
66
*/
77
'use strict'
8-
exports[`test/lib/utils/explain-dep.js TAP > ellipses test one 1`] = `
8+
exports[`test/lib/utils/explain-dep.js TAP basic > ellipses test one 1`] = `
99
manydep@1.0.0
1010
manydep@"1.0.0" from prod-dep@1.2.3
1111
node_modules/prod-dep
1212
prod-dep@"1.x" from the root project
1313
7 more (optdep, extra-neos, deep-dev, peer, the root project, ...)
1414
`
1515

16-
exports[`test/lib/utils/explain-dep.js TAP > ellipses test two 1`] = `
16+
exports[`test/lib/utils/explain-dep.js TAP basic > ellipses test two 1`] = `
1717
manydep@1.0.0
1818
manydep@"1.0.0" from prod-dep@1.2.3
1919
node_modules/prod-dep
2020
prod-dep@"1.x" from the root project
2121
6 more (optdep, extra-neos, deep-dev, peer, the root project, a package with a pretty long name)
2222
`
2323

24-
exports[`test/lib/utils/explain-dep.js TAP bundled > explain color deep 1`] = `
24+
exports[`test/lib/utils/explain-dep.js TAP basic bundled > explain color deep 1`] = `
2525
bundle-of-joy@1.0.0 bundled
2626
node_modules/bundle-of-joy
2727
bundled prod-dep@"1.x" from the root project
2828
`
2929

30-
exports[`test/lib/utils/explain-dep.js TAP bundled > explain nocolor shallow 1`] = `
30+
exports[`test/lib/utils/explain-dep.js TAP basic bundled > explain nocolor shallow 1`] = `
3131
bundle-of-joy@1.0.0 bundled
3232
node_modules/bundle-of-joy
3333
bundled prod-dep@"1.x" from the root project
3434
`
3535

36-
exports[`test/lib/utils/explain-dep.js TAP bundled > print color 1`] = `
36+
exports[`test/lib/utils/explain-dep.js TAP basic bundled > print color 1`] = `
3737
bundle-of-joy@1.0.0 bundled
3838
node_modules/bundle-of-joy
3939
`
4040

41-
exports[`test/lib/utils/explain-dep.js TAP bundled > print nocolor 1`] = `
41+
exports[`test/lib/utils/explain-dep.js TAP basic bundled > print nocolor 1`] = `
4242
bundle-of-joy@1.0.0 bundled
4343
node_modules/bundle-of-joy
4444
`
4545

46-
exports[`test/lib/utils/explain-dep.js TAP deepDev > explain color deep 1`] = `
46+
exports[`test/lib/utils/explain-dep.js TAP basic deepDev > explain color deep 1`] = `
4747
deep-dev@2.3.4 dev
4848
node_modules/deep-dev
4949
deep-dev@"2.x" from metadev@3.4.5
@@ -53,7 +53,7 @@ exports[`test/lib/utils/explain-dep.js TAP deepDev > explain color deep 1`] = `
5353
dev topdev@"4.x" from the root project
5454
`
5555

56-
exports[`test/lib/utils/explain-dep.js TAP deepDev > explain nocolor shallow 1`] = `
56+
exports[`test/lib/utils/explain-dep.js TAP basic deepDev > explain nocolor shallow 1`] = `
5757
deep-dev@2.3.4 dev
5858
node_modules/deep-dev
5959
deep-dev@"2.x" from metadev@3.4.5
@@ -62,37 +62,37 @@ node_modules/deep-dev
6262
node_modules/topdev
6363
`
6464

65-
exports[`test/lib/utils/explain-dep.js TAP deepDev > print color 1`] = `
65+
exports[`test/lib/utils/explain-dep.js TAP basic deepDev > print color 1`] = `
6666
deep-dev@2.3.4 dev
6767
node_modules/deep-dev
6868
`
6969

70-
exports[`test/lib/utils/explain-dep.js TAP deepDev > print nocolor 1`] = `
70+
exports[`test/lib/utils/explain-dep.js TAP basic deepDev > print nocolor 1`] = `
7171
deep-dev@2.3.4 dev
7272
node_modules/deep-dev
7373
`
7474

75-
exports[`test/lib/utils/explain-dep.js TAP extraneous > explain color deep 1`] = `
75+
exports[`test/lib/utils/explain-dep.js TAP basic extraneous > explain color deep 1`] = `
7676
extra-neos@1337.420.69-lol extraneous
7777
node_modules/extra-neos
7878
`
7979

80-
exports[`test/lib/utils/explain-dep.js TAP extraneous > explain nocolor shallow 1`] = `
80+
exports[`test/lib/utils/explain-dep.js TAP basic extraneous > explain nocolor shallow 1`] = `
8181
extra-neos@1337.420.69-lol extraneous
8282
node_modules/extra-neos
8383
`
8484

85-
exports[`test/lib/utils/explain-dep.js TAP extraneous > print color 1`] = `
85+
exports[`test/lib/utils/explain-dep.js TAP basic extraneous > print color 1`] = `
8686
extra-neos@1337.420.69-lol extraneous
8787
node_modules/extra-neos
8888
`
8989

90-
exports[`test/lib/utils/explain-dep.js TAP extraneous > print nocolor 1`] = `
90+
exports[`test/lib/utils/explain-dep.js TAP basic extraneous > print nocolor 1`] = `
9191
extra-neos@1337.420.69-lol extraneous
9292
node_modules/extra-neos
9393
`
9494

95-
exports[`test/lib/utils/explain-dep.js TAP manyDeps > explain color deep 1`] = `
95+
exports[`test/lib/utils/explain-dep.js TAP basic manyDeps > explain color deep 1`] = `
9696
manydep@1.0.0
9797
manydep@"1.0.0" from prod-dep@1.2.3
9898
node_modules/prod-dep
@@ -118,132 +118,132 @@ exports[`test/lib/utils/explain-dep.js TAP manyDeps > explain color deep 1`] = `
118118
manydep@"1" from yet another a package with a pretty long name@1.2.3
119119
`
120120

121-
exports[`test/lib/utils/explain-dep.js TAP manyDeps > explain nocolor shallow 1`] = `
121+
exports[`test/lib/utils/explain-dep.js TAP basic manyDeps > explain nocolor shallow 1`] = `
122122
manydep@1.0.0
123123
manydep@"1.0.0" from prod-dep@1.2.3
124124
node_modules/prod-dep
125125
prod-dep@"1.x" from the root project
126126
8 more (optdep, extra-neos, deep-dev, peer, the root project, ...)
127127
`
128128

129-
exports[`test/lib/utils/explain-dep.js TAP manyDeps > print color 1`] = `
129+
exports[`test/lib/utils/explain-dep.js TAP basic manyDeps > print color 1`] = `
130130
manydep@1.0.0
131131
`
132132

133-
exports[`test/lib/utils/explain-dep.js TAP manyDeps > print nocolor 1`] = `
133+
exports[`test/lib/utils/explain-dep.js TAP basic manyDeps > print nocolor 1`] = `
134134
manydep@1.0.0
135135
`
136136

137-
exports[`test/lib/utils/explain-dep.js TAP optional > explain color deep 1`] = `
137+
exports[`test/lib/utils/explain-dep.js TAP basic optional > explain color deep 1`] = `
138138
optdep@1.0.0 optional
139139
node_modules/optdep
140140
optional optdep@"1.0.0" from the root project
141141
`
142142

143-
exports[`test/lib/utils/explain-dep.js TAP optional > explain nocolor shallow 1`] = `
143+
exports[`test/lib/utils/explain-dep.js TAP basic optional > explain nocolor shallow 1`] = `
144144
optdep@1.0.0 optional
145145
node_modules/optdep
146146
optional optdep@"1.0.0" from the root project
147147
`
148148

149-
exports[`test/lib/utils/explain-dep.js TAP optional > print color 1`] = `
149+
exports[`test/lib/utils/explain-dep.js TAP basic optional > print color 1`] = `
150150
optdep@1.0.0 optional
151151
node_modules/optdep
152152
`
153153

154-
exports[`test/lib/utils/explain-dep.js TAP optional > print nocolor 1`] = `
154+
exports[`test/lib/utils/explain-dep.js TAP basic optional > print nocolor 1`] = `
155155
optdep@1.0.0 optional
156156
node_modules/optdep
157157
`
158158

159-
exports[`test/lib/utils/explain-dep.js TAP overridden > explain color deep 1`] = `
159+
exports[`test/lib/utils/explain-dep.js TAP basic overridden > explain color deep 1`] = `
160160
overridden-root@1.0.0 overridden
161161
node_modules/overridden-root
162162
overridden overridden-dep@"1.0.0" (was "^2.0.0") from the root project
163163
`
164164

165-
exports[`test/lib/utils/explain-dep.js TAP overridden > explain nocolor shallow 1`] = `
165+
exports[`test/lib/utils/explain-dep.js TAP basic overridden > explain nocolor shallow 1`] = `
166166
overridden-root@1.0.0 overridden
167167
node_modules/overridden-root
168168
overridden overridden-dep@"1.0.0" (was "^2.0.0") from the root project
169169
`
170170

171-
exports[`test/lib/utils/explain-dep.js TAP overridden > print color 1`] = `
171+
exports[`test/lib/utils/explain-dep.js TAP basic overridden > print color 1`] = `
172172
overridden-root@1.0.0 overridden
173173
node_modules/overridden-root
174174
`
175175

176-
exports[`test/lib/utils/explain-dep.js TAP overridden > print nocolor 1`] = `
176+
exports[`test/lib/utils/explain-dep.js TAP basic overridden > print nocolor 1`] = `
177177
overridden-root@1.0.0 overridden
178178
node_modules/overridden-root
179179
`
180180

181-
exports[`test/lib/utils/explain-dep.js TAP peer > explain color deep 1`] = `
181+
exports[`test/lib/utils/explain-dep.js TAP basic peer > explain color deep 1`] = `
182182
peer@1.0.0 peer
183183
node_modules/peer
184184
peer peer@"1.0.0" from the root project
185185
`
186186

187-
exports[`test/lib/utils/explain-dep.js TAP peer > explain nocolor shallow 1`] = `
187+
exports[`test/lib/utils/explain-dep.js TAP basic peer > explain nocolor shallow 1`] = `
188188
peer@1.0.0 peer
189189
node_modules/peer
190190
peer peer@"1.0.0" from the root project
191191
`
192192

193-
exports[`test/lib/utils/explain-dep.js TAP peer > print color 1`] = `
193+
exports[`test/lib/utils/explain-dep.js TAP basic peer > print color 1`] = `
194194
peer@1.0.0 peer
195195
node_modules/peer
196196
`
197197

198-
exports[`test/lib/utils/explain-dep.js TAP peer > print nocolor 1`] = `
198+
exports[`test/lib/utils/explain-dep.js TAP basic peer > print nocolor 1`] = `
199199
peer@1.0.0 peer
200200
node_modules/peer
201201
`
202202

203-
exports[`test/lib/utils/explain-dep.js TAP prodDep > explain color deep 1`] = `
203+
exports[`test/lib/utils/explain-dep.js TAP basic prodDep > explain color deep 1`] = `
204204
prod-dep@1.2.3
205205
node_modules/prod-dep
206206
prod-dep@"1.x" from the root project
207207
`
208208

209-
exports[`test/lib/utils/explain-dep.js TAP prodDep > explain nocolor shallow 1`] = `
209+
exports[`test/lib/utils/explain-dep.js TAP basic prodDep > explain nocolor shallow 1`] = `
210210
prod-dep@1.2.3
211211
node_modules/prod-dep
212212
prod-dep@"1.x" from the root project
213213
`
214214

215-
exports[`test/lib/utils/explain-dep.js TAP prodDep > print color 1`] = `
215+
exports[`test/lib/utils/explain-dep.js TAP basic prodDep > print color 1`] = `
216216
prod-dep@1.2.3
217217
node_modules/prod-dep
218218
`
219219

220-
exports[`test/lib/utils/explain-dep.js TAP prodDep > print nocolor 1`] = `
220+
exports[`test/lib/utils/explain-dep.js TAP basic prodDep > print nocolor 1`] = `
221221
prod-dep@1.2.3
222222
node_modules/prod-dep
223223
`
224224

225-
exports[`test/lib/utils/explain-dep.js TAP workspaces > explain color deep 1`] = `
225+
exports[`test/lib/utils/explain-dep.js TAP basic workspaces > explain color deep 1`] = `
226226
a@1.0.0
227227
a
228228
a@1.0.0
229229
node_modules/a
230230
workspace a from the root project
231231
`
232232

233-
exports[`test/lib/utils/explain-dep.js TAP workspaces > explain nocolor shallow 1`] = `
233+
exports[`test/lib/utils/explain-dep.js TAP basic workspaces > explain nocolor shallow 1`] = `
234234
a@1.0.0
235235
a
236236
a@1.0.0
237237
node_modules/a
238238
workspace a from the root project
239239
`
240240

241-
exports[`test/lib/utils/explain-dep.js TAP workspaces > print color 1`] = `
241+
exports[`test/lib/utils/explain-dep.js TAP basic workspaces > print color 1`] = `
242242
a@1.0.0
243243
a
244244
`
245245

246-
exports[`test/lib/utils/explain-dep.js TAP workspaces > print nocolor 1`] = `
246+
exports[`test/lib/utils/explain-dep.js TAP basic workspaces > print nocolor 1`] = `
247247
a@1.0.0
248248
a
249249
`

‎tap-snapshots/test/lib/utils/explain-eresolve.js.test.cjs

+35-35
Large diffs are not rendered by default.

‎test/lib/commands/help-search.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const t = require('tap')
22
const { load: loadMockNpm } = require('../../fixtures/mock-npm.js')
3-
const chalk = require('chalk')
43

54
/* eslint-disable max-len */
65
const docsFixtures = {
@@ -70,6 +69,8 @@ t.test('npm help-search long output with color', async t => {
7069
},
7170
})
7271

72+
const chalk = await import('chalk').then(v => v.default)
73+
7374
const highlightedText = chalk.bgBlack.red('help-search')
7475
t.equal(
7576
output.split('\n').some(line => line.includes(highlightedText)),

‎test/lib/utils/ansi-trim.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const t = require('tap')
22
const ansiTrim = require('../../../lib/utils/ansi-trim.js')
3-
const chalk = require('chalk')
4-
t.equal(ansiTrim('foo'), 'foo', 'does nothing if no ansis')
5-
t.equal(ansiTrim(chalk.red('foo')), 'foo', 'strips out ansis')
3+
4+
t.test('basic', async t => {
5+
const chalk = await import('chalk').then(v => v.default)
6+
t.equal(ansiTrim('foo'), 'foo', 'does nothing if no ansis')
7+
t.equal(ansiTrim(chalk.red('foo')), 'foo', 'strips out ansis')
8+
})

‎test/lib/utils/explain-dep.js

+237-229
Large diffs are not rendered by default.

‎test/lib/utils/explain-eresolve.js

+19-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
const t = require('tap')
2-
const Chalk = require('chalk')
32
const { explain, report } = require('../../../lib/utils/explain-eresolve.js')
43

54
const cases = require('../../fixtures/eresolve-explanations.js')
65

7-
const color = new Chalk.Instance({ level: Chalk.level })
8-
const noColor = new Chalk.Instance({ level: 0 })
6+
t.test('basic', async t => {
7+
const { Chalk } = await import('chalk')
8+
const color = new Chalk({ level: 3 })
9+
const noColor = new Chalk({ level: 0 })
910

10-
for (const [name, expl] of Object.entries(cases)) {
11+
for (const [name, expl] of Object.entries(cases)) {
1112
// no sense storing the whole contents of each object in the snapshot
1213
// we can trust that JSON.stringify still works just fine.
13-
expl.toJSON = () => ({ name, json: true })
14+
expl.toJSON = () => ({ name, json: true })
1415

15-
t.test(name, t => {
16-
const colorReport = report(expl, color, noColor)
17-
t.matchSnapshot(colorReport.explanation, 'report with color')
18-
t.matchSnapshot(colorReport.file, 'report from color')
16+
t.test(name, t => {
17+
const colorReport = report(expl, color, noColor)
18+
t.matchSnapshot(colorReport.explanation, 'report with color')
19+
t.matchSnapshot(colorReport.file, 'report from color')
1920

20-
const noColorReport = report(expl, noColor, noColor)
21-
t.matchSnapshot(noColorReport.explanation, 'report with no color')
22-
t.equal(noColorReport.file, colorReport.file, 'same report written for object')
21+
const noColorReport = report(expl, noColor, noColor)
22+
t.matchSnapshot(noColorReport.explanation, 'report with no color')
23+
t.equal(noColorReport.file, colorReport.file, 'same report written for object')
2324

24-
t.matchSnapshot(explain(expl, color, 2), 'explain with color, depth of 2')
25-
t.matchSnapshot(explain(expl, noColor, 6), 'explain with no color, depth of 6')
25+
t.matchSnapshot(explain(expl, color, 2), 'explain with color, depth of 2')
26+
t.matchSnapshot(explain(expl, noColor, 6), 'explain with no color, depth of 6')
2627

27-
t.end()
28-
})
29-
}
28+
t.end()
29+
})
30+
}
31+
})

0 commit comments

Comments
 (0)
Please sign in to comment.