MCPcopy Index your code
hub / github.com/Waishnav/devspace / startPty

Method startPty

src/process-sessions.ts:342–373  ·  view source on GitHub ↗
(session: ProcessSession, input: StartCommandInput)

Source from the content-addressed store, hash-verified

340 }
341
342 private async startPty(session: ProcessSession, input: StartCommandInput): Promise<void> {
343 let nodePty: typeof import("node-pty");
344 try {
345 nodePty = await import("node-pty");
346 } catch {
347 throw new Error("PTY support requires the optional node-pty dependency.");
348 }
349
350 const shell = resolveShellCommand(input.command);
351 let pty: import("node-pty").IPty;
352 try {
353 pty = nodePty.spawn(shell.executable, shell.args, {
354 cwd: input.cwd,
355 env: processEnvironment(),
356 name: "xterm-256color",
357 cols: session.columns,
358 rows: session.rows,
359 });
360 } catch (error) {
361 throw error;
362 }
363
364 session.process = {
365 write: (data) => pty.write(data),
366 kill: (signal) => pty.kill(signal),
367 resize: (columns, rows) => pty.resize(columns, rows),
368 };
369 pty.onData((data) => this.append(session, data));
370 pty.onExit(({ exitCode, signal }) => {
371 this.finish(session, exitCode, signal === 0 ? undefined : String(signal));
372 });
373 }
374
375 private finish(session: ProcessSession, exitCode?: number, signal?: string): void {
376 if (!session.running) return;

Callers 1

startMethod · 0.95

Calls 7

appendMethod · 0.95
finishMethod · 0.95
resolveShellCommandFunction · 0.85
processEnvironmentFunction · 0.85
resizeMethod · 0.80
writeMethod · 0.65
killMethod · 0.65

Tested by

no test coverage detected