@@ -3,7 +3,6 @@ const relativePrefix = `.${sep}`
3
3
const { EOL } = require ( 'os' )
4
4
5
5
const archy = require ( 'archy' )
6
- const chalk = require ( 'chalk' )
7
6
const Arborist = require ( '@npmcli/arborist' )
8
7
const { breadth } = require ( 'treeverse' )
9
8
const npa = require ( 'npm-package-arg' )
@@ -50,7 +49,7 @@ class LS extends ArboristWorkspaceCmd {
50
49
51
50
async exec ( args ) {
52
51
const all = this . npm . config . get ( 'all' )
53
- const color = this . npm . color
52
+ const chalk = this . npm . chalk
54
53
const depth = this . npm . config . get ( 'depth' )
55
54
const global = this . npm . global
56
55
const json = this . npm . config . get ( 'json' )
@@ -157,7 +156,7 @@ class LS extends ArboristWorkspaceCmd {
157
156
? getJsonOutputItem ( node , { global, long } )
158
157
: parseable
159
158
? null
160
- : getHumanOutputItem ( node , { args, color , global, long } )
159
+ : getHumanOutputItem ( node , { args, chalk , global, long } )
161
160
162
161
// loop through list of node problems to add them to global list
163
162
if ( node [ _include ] ) {
@@ -180,7 +179,7 @@ class LS extends ArboristWorkspaceCmd {
180
179
this . npm . outputBuffer (
181
180
json ? jsonOutput ( { path, problems, result, rootError, seenItems } ) :
182
181
parseable ? parseableOutput ( { seenNodes, global, long } ) :
183
- humanOutput ( { color , result, seenItems, unicode } )
182
+ humanOutput ( { chalk , result, seenItems, unicode } )
184
183
)
185
184
186
185
// if filtering items, should exit with error code on no results
@@ -278,9 +277,9 @@ const augmentItemWithIncludeMetadata = (node, item) => {
278
277
return item
279
278
}
280
279
281
- const getHumanOutputItem = ( node , { args, color , global, long } ) => {
280
+ const getHumanOutputItem = ( node , { args, chalk , global, long } ) => {
282
281
const { pkgid, path } = node
283
- const workspacePkgId = color ? chalk . green ( pkgid ) : pkgid
282
+ const workspacePkgId = chalk . green ( pkgid )
284
283
let printable = node . isWorkspace ? workspacePkgId : pkgid
285
284
286
285
// special formatting for top-level package name
@@ -293,8 +292,7 @@ const getHumanOutputItem = (node, { args, color, global, long }) => {
293
292
}
294
293
}
295
294
296
- const highlightDepName =
297
- color && args . length && node [ _filteredBy ]
295
+ const highlightDepName = args . length && node [ _filteredBy ]
298
296
const missingColor = isOptional ( node )
299
297
? chalk . yellow . bgBlack
300
298
: chalk . red . bgBlack
@@ -308,28 +306,28 @@ const getHumanOutputItem = (node, { args, color, global, long }) => {
308
306
const label =
309
307
(
310
308
node [ _missing ]
311
- ? ( color ? missingColor ( missingMsg ) : missingMsg ) + ' '
309
+ ? missingColor ( missingMsg ) + ' '
312
310
: ''
313
311
) +
314
312
`${ highlightDepName ? chalk . yellow . bgBlack ( printable ) : printable } ` +
315
313
(
316
314
node [ _dedupe ]
317
- ? ' ' + ( color ? chalk . gray ( 'deduped' ) : 'deduped' )
315
+ ? ' ' + chalk . gray ( 'deduped' )
318
316
: ''
319
317
) +
320
318
(
321
319
invalid
322
- ? ' ' + ( color ? chalk . red . bgBlack ( invalid ) : invalid )
320
+ ? ' ' + chalk . red . bgBlack ( invalid )
323
321
: ''
324
322
) +
325
323
(
326
324
isExtraneous ( node , { global } )
327
- ? ' ' + ( color ? chalk . green . bgBlack ( 'extraneous' ) : 'extraneous' )
325
+ ? ' ' + chalk . green . bgBlack ( 'extraneous' )
328
326
: ''
329
327
) +
330
328
(
331
329
node . overridden
332
- ? ' ' + ( color ? chalk . gray ( 'overridden' ) : 'overridden' )
330
+ ? ' ' + chalk . gray ( 'overridden' )
333
331
: ''
334
332
) +
335
333
( isGitNode ( node ) ? ` (${ node . resolved } )` : '' ) +
@@ -504,7 +502,7 @@ const augmentNodesWithMetadata = ({
504
502
505
503
const sortAlphabetically = ( { pkgid : a } , { pkgid : b } ) => localeCompare ( a , b )
506
504
507
- const humanOutput = ( { color , result, seenItems, unicode } ) => {
505
+ const humanOutput = ( { chalk , result, seenItems, unicode } ) => {
508
506
// we need to traverse the entire tree in order to determine which items
509
507
// should be included (since a nested transitive included dep will make it
510
508
// so that all its ancestors should be displayed)
@@ -520,7 +518,7 @@ const humanOutput = ({ color, result, seenItems, unicode }) => {
520
518
}
521
519
522
520
const archyOutput = archy ( result , '' , { unicode } )
523
- return color ? chalk . reset ( archyOutput ) : archyOutput
521
+ return chalk . reset ( archyOutput )
524
522
}
525
523
526
524
const jsonOutput = ( { path, problems, result, rootError, seenItems } ) => {
0 commit comments