( root: string, failedProjectScanError: FailedProjectScanError, destination: Writable, )
| 197 | * to the destination stream in a format consistent with printDepGraphJsonl. |
| 198 | */ |
| 199 | export async function printDepGraphError( |
| 200 | root: string, |
| 201 | failedProjectScanError: FailedProjectScanError, |
| 202 | destination: Writable, |
| 203 | ): Promise<void> { |
| 204 | return new Promise((res, rej) => { |
| 205 | // Normalize the target file path to be relative to root, consistent with printDepGraphJsonl |
| 206 | const normalisedTargetFile = failedProjectScanError.targetFile |
| 207 | ? path.relative(root, failedProjectScanError.targetFile) |
| 208 | : failedProjectScanError.targetFile; |
| 209 | |
| 210 | const problemError = getOrCreateErrorCatalogError(failedProjectScanError); |
| 211 | const serializedError = problemError.toJsonApi().body(); |
| 212 | |
| 213 | const errorRecord = { |
| 214 | error: serializedError, |
| 215 | normalisedTargetFile, |
| 216 | }; |
| 217 | |
| 218 | new ConcatStream(new JsonStreamStringify(errorRecord), Readable.from('\n')) |
| 219 | .on('end', res) |
| 220 | .on('error', rej) |
| 221 | .pipe(destination); |
| 222 | }); |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Checks if either --print-effective-graph or --print-effective-graph-with-errors is set. |
no test coverage detected