MCPcopy Index your code
hub / github.com/MiniMax-AI/cli / withTTY

Function withTTY

test/utils/env.test.ts:4–21  ·  view source on GitHub ↗
(stdout: boolean, stdin: boolean, fn: () => void)

Source from the content-addressed store, hash-verified

2import { isInteractive, isCI } from '../../src/utils/env';
3
4function withTTY(stdout: boolean, stdin: boolean, fn: () => void): void {
5 const origStdout = Object.getOwnPropertyDescriptor(process.stdout, 'isTTY');
6 const origStdin = Object.getOwnPropertyDescriptor(process.stdin, 'isTTY');
7 Object.defineProperty(process.stdout, 'isTTY', { value: stdout, configurable: true });
8 Object.defineProperty(process.stdin, 'isTTY', { value: stdin, configurable: true });
9 try { fn(); } finally {
10 if (origStdout) {
11 Object.defineProperty(process.stdout, 'isTTY', origStdout);
12 } else {
13 delete (process.stdout as unknown as Record<string, unknown>).isTTY;
14 }
15 if (origStdin) {
16 Object.defineProperty(process.stdin, 'isTTY', origStdin);
17 } else {
18 delete (process.stdin as unknown as Record<string, unknown>).isTTY;
19 }
20 }
21}
22
23describe('isInteractive', () => {
24 // Ensure CI env is clean before each test — other test files may set it

Callers 1

env.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected