MCPcopy Index your code
hub / github.com/react/react / writeOutputToString

Function writeOutputToString

compiler/packages/snap/src/reporter.ts:21–65  ·  view source on GitHub ↗
(
  input: string,
  compilerOutput: string | null,
  evaluatorOutput: string | null,
  logs: string | null,
  errorMessage: string | null,
)

Source from the content-addressed store, hash-verified

19const SPROUT_SEPARATOR = '\n### Eval output\n';
20
21export function writeOutputToString(
22 input: string,
23 compilerOutput: string | null,
24 evaluatorOutput: string | null,
25 logs: string | null,
26 errorMessage: string | null,
27) {
28 // leading newline intentional
29 let result = `
30## Input
31
32${wrapWithTripleBackticks(input, 'javascript')}
33`; // trailing newline + space internional
34
35 if (compilerOutput != null) {
36 result += `
37## Code
38
39${wrapWithTripleBackticks(compilerOutput, 'javascript')}
40`;
41 } else {
42 result += '\n';
43 }
44
45 if (logs != null) {
46 result += `
47## Logs
48
49${wrapWithTripleBackticks(logs, null)}
50`;
51 }
52
53 if (errorMessage != null) {
54 result += `
55## Error
56
57${wrapWithTripleBackticks(errorMessage.replace(/^\/.*?:\s/, ''))}
58 \n`;
59 }
60 result += ` `;
61 if (evaluatorOutput != null) {
62 result += SPROUT_SEPARATOR + evaluatorOutput;
63 }
64 return result;
65}
66
67export type TestResult = {
68 actual: string | null; // null == input did not exist

Callers 1

transformFixtureFunction · 0.90

Calls 1

wrapWithTripleBackticksFunction · 0.85

Tested by

no test coverage detected