3422e6edc1
- stdin.ref() on raw mode enable, stdin.unref() on disable
- setEncoding("utf8") on raw mode enable
- Raw mode default changed from true to false (hooks acquire it)
- useStdin().setRawMode routed through ref-counted controller
- Stdin listeners attached only when raw mode is active
- EventEmitter maxListeners set to Infinity
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
33 lines
799 B
TypeScript
33 lines
799 B
TypeScript
import { PassThrough } from "node:stream";
|
|
|
|
export interface FakeWritableOptions {
|
|
columns?: number;
|
|
rows?: number;
|
|
}
|
|
|
|
export function makeFakeWritable(options: FakeWritableOptions = {}): NodeJS.WriteStream {
|
|
const s = new PassThrough() as unknown as NodeJS.WriteStream;
|
|
Object.assign(s, {
|
|
columns: options.columns ?? 100,
|
|
rows: options.rows ?? 100,
|
|
isTTY: true,
|
|
});
|
|
return s;
|
|
}
|
|
|
|
export function makeFakeStdin(): { stream: NodeJS.ReadStream } {
|
|
const s = new PassThrough() as unknown as NodeJS.ReadStream;
|
|
Object.assign(s, {
|
|
isTTY: true,
|
|
setRawMode(this: NodeJS.ReadStream) {
|
|
return this;
|
|
},
|
|
setEncoding(this: NodeJS.ReadStream) {
|
|
return this;
|
|
},
|
|
});
|
|
(s as any).ref = () => {};
|
|
(s as any).unref = () => {};
|
|
return { stream: s };
|
|
}
|