@@ -21,7 +21,7 @@ import {
21
21
VersionNotFoundError ,
22
22
} from "../domain/packument" ;
23
23
import { PackumentNotFoundError } from "../common-errors" ;
24
- import { make } from "ts-brand " ;
24
+ import { Chalk } from "chalk " ;
25
25
26
26
/**
27
27
* Logs information about a resolved dependency to a logger.
@@ -73,15 +73,21 @@ export function logFailedDependency(
73
73
* @param graph The graph.
74
74
* @param rootPackage The name of the graphs root package.
75
75
* @param rootVersion The version of the graphs root package.
76
+ * @param chalk Used for coloring output. Omit if no color should be used.
76
77
* @returns A string array representing the graph. Each string is a line.
77
78
*/
78
79
export function stringifyDependencyGraph (
79
80
graph : DependencyGraph ,
80
81
rootPackage : DomainName ,
81
- rootVersion : SemanticVersion
82
+ rootVersion : SemanticVersion ,
83
+ chalk ?: Chalk
82
84
) : readonly string [ ] {
83
85
const printedRefs = new Set < PackageReference > ( ) ;
84
86
87
+ function tryColor ( chalk : Chalk | undefined , s : string ) {
88
+ return chalk !== undefined ? chalk ( s ) : s ;
89
+ }
90
+
85
91
function getNode (
86
92
packageName : DomainName ,
87
93
version : SemanticVersion
@@ -109,7 +115,7 @@ export function stringifyDependencyGraph(
109
115
}
110
116
111
117
function makeDuplicateLine ( packageRef : PackageReference ) : string {
112
- return `${ packageRef } ..` ;
118
+ return tryColor ( chalk ?. blueBright , `${ packageRef } ..` ) ;
113
119
}
114
120
115
121
function makeErrorLines ( errors : FailedNode [ "errors" ] ) : readonly string [ ] {
@@ -174,7 +180,7 @@ export function stringifyDependencyGraph(
174
180
- url2: package not found
175
181
*/
176
182
const errorLines = makeErrorLines ( node . errors ) ;
177
- return [ packageRef , ...errorLines ] ;
183
+ return [ tryColor ( chalk ?. red , packageRef ) , ...errorLines ] ;
178
184
}
179
185
180
186
// Resolved node
0 commit comments