MCPcopy Create free account
hub / github.com/callstack/agent-device / withColor

Function withColor

src/utils/__tests__/output.test.ts:1512–1525  ·  view source on GitHub ↗
(fn: () => T)

Source from the content-addressed store, hash-verified

1510}
1511
1512function withColor<T>(fn: () => T): T {
1513 const originalForceColor = process.env.FORCE_COLOR;
1514 const originalNoColor = process.env.NO_COLOR;
1515 process.env.FORCE_COLOR = '1';
1516 delete process.env.NO_COLOR;
1517 try {
1518 return fn();
1519 } finally {
1520 if (typeof originalForceColor === 'string') process.env.FORCE_COLOR = originalForceColor;
1521 else delete process.env.FORCE_COLOR;
1522 if (typeof originalNoColor === 'string') process.env.NO_COLOR = originalNoColor;
1523 else delete process.env.NO_COLOR;
1524 }
1525}
1526
1527test('formatScreenshotDiffText renders match success without color', () => {
1528 const text = withNoColor(() =>

Callers 1

output.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…