MCPcopy
hub / github.com/snyk/cli / printDepGraphError

Function printDepGraphError

src/lib/snyk-test/common.ts:199–223  ·  view source on GitHub ↗
(
  root: string,
  failedProjectScanError: FailedProjectScanError,
  destination: Writable,
)

Source from the content-addressed store, hash-verified

197 * to the destination stream in a format consistent with printDepGraphJsonl.
198 */
199export 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.

Callers 2

assembleLocalPayloadsFunction · 0.90
executeTestFunction · 0.85

Calls 1

Tested by

no test coverage detected