MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / attachStream

Function attachStream

src/utils/command.ts:144–179  ·  view source on GitHub ↗
(
      stream: NodeJS.ReadableStream | null | undefined,
      onChunk: (chunk: string) => void,
    )

Source from the content-addressed store, hash-verified

142 };
143
144 const attachStream = (
145 stream: NodeJS.ReadableStream | null | undefined,
146 onChunk: (chunk: string) => void,
147 ): void => {
148 if (!stream) {
149 return;
150 }
151
152 openStreamCount += 1;
153 let streamClosed = false;
154
155 const markClosed = (): void => {
156 if (streamClosed) {
157 return;
158 }
159 streamClosed = true;
160 openStreamCount = Math.max(0, openStreamCount - 1);
161 maybeSettleAfterExit();
162 };
163
164 const handleData = (data: Buffer | string): void => {
165 if (settled) {
166 return;
167 }
168 const chunk = data.toString();
169 onChunk(chunk);
170 };
171
172 stream.on('data', handleData);
173 stream.once('end', markClosed);
174 stream.once('close', markClosed);
175 streamClosers.push(markClosed);
176 streamDetachers.push(() => {
177 stream.off('data', handleData);
178 });
179 };
180
181 if (detached) {
182 let resolved = false;

Callers 1

defaultExecutorFunction · 0.85

Calls 2

pushMethod · 0.80
onceMethod · 0.65

Tested by

no test coverage detected