A utility to execute shell commands with support for timeouts, abort signals, and process management. Use this when building CLI tools or automation tasks that require external process control.
// Source: https://github.com/AVIDS2/memorix | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Shared command execution utilities for extensions and custom tools.
*/
import { spawn } from "node:child_process";
import { waitForChildProcess } from "../utils/child-process.ts";
/**
* Options for executing shell commands.
*/
export interface ExecOptions {
/** AbortSignal to cancel the command */
signal?: AbortSignal;
/** Timeout in milliseconds */
timeout?: number;
/** Working directory */
cwd?: string;
}
/**
* Result of executing a shell command.
*/
export interface ExecResult {
stdout: string;
stderr: string;
code: number;
killed: boolean;
}
/**
* Execute a s
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key