/** * @fileoverview Cross-platform utilities for subprocess execution * and path operations. Abstracts Windows/macOS/Linux differences. * * All imports must use .js extension for ESM module resolution. */ export type { PreparedSpawn, PrepareSpawnOptions } from './windows-spawn.js'; export { prepareSpawn } from './windows-spawn.js'; /** Whether the current platform is Windows */ export declare const isWindows: boolean; /** Whether the current platform is macOS */ export declare const isMac: boolean; /** Whether the current platform is Linux */ export declare const isLinux: boolean; /** Error codes for exec() failures */ export declare enum ExecErrorCode { /** Process exceeded timeout */ TIMEOUT = "TIMEOUT", /** Process was killed by a signal */ SIGNAL = "SIGNAL", /** Process exited with non-zero exit code */ EXIT_CODE = "EXIT_CODE", /** Failed to spawn the process */ SPAWN_FAILED = "SPAWN_FAILED", /** stdout or stderr exceeded `maxOutputBytes`; the process was killed */ OUTPUT_LIMIT_EXCEEDED = "OUTPUT_LIMIT_EXCEEDED" } /** Default for {@link ExecOptions.maxOutputBytes}: 10 MiB per stream. */ export declare const DEFAULT_MAX_OUTPUT_BYTES: number; /** Options for cross-platform exec */ export interface ExecOptions { /** Working directory */ cwd?: string; /** Timeout in milliseconds */ timeout?: number; /** Enable debug logging of commands (default: false) */ debug?: boolean; /** Environment variables to merge with process.env */ env?: Record; /** * Maximum bytes captured from each of stdout and stderr (default: * {@link DEFAULT_MAX_OUTPUT_BYTES}, 10 MiB). When either stream exceeds it, * the process is killed and the result has `errorCode` * `OUTPUT_LIMIT_EXCEEDED`, with the output captured up to the limit. */ maxOutputBytes?: number; } /** Result from exec() with error codes for observability */ export interface ExecResult { /** Standard output (trimmed) */ stdout: string; /** Standard error (trimmed) */ stderr: string; /** Process exit code */ exitCode: number; /** Error code if failed, undefined if success */ errorCode?: ExecErrorCode; /** Duration in milliseconds */ durationMs: number; } /** * Factory function for ExecResult. * Follows afd-core pattern from errors.ts, streaming.ts. */ export declare function createExecResult(stdout: string, stderr: string, exitCode: number, durationMs: number, errorCode?: ExecErrorCode): ExecResult; /** * Type guard: check if ExecResult indicates an error. */ export declare function isExecError(result: ExecResult): boolean; /** * Execute a command with cross-platform support. * * Never uses `shell: true`. On Windows, `.cmd`/`.bat` commands (such as `npm`) run through * cmd.exe with every argument escaped; see {@link prepareSpawn}. * * @param cmd - Command as array of strings [command, ...args] * @param options - Execution options * @returns Promise resolving to ExecResult * * @example * ```typescript * const result = await exec(['git', 'status']); * if (!isExecError(result)) { * console.log(result.stdout); * } * ``` */ export declare function exec(cmd: string[], options?: ExecOptions): Promise; /** * Find a file by walking up parent directories. * * @param filename - Name of file to find * @param cwd - Starting directory (defaults to process.cwd()) * @returns Absolute path to found file, or null if not found * * @example * ```typescript * const packageJson = findUp('package.json'); * if (packageJson) { * console.log('Found at:', packageJson); * } * ``` */ export declare function findUp(filename: string, cwd?: string): string | null; /** * Get the system temporary directory. * * @returns Path to the system temp directory * * @example * ```typescript * const tempDir = getTempDir(); * // Windows: 'C:\\Users\\...\\AppData\\Local\\Temp' * // macOS/Linux: '/tmp' * ``` */ export declare function getTempDir(): string; /** * Normalize a path to use the platform's path separator. * * @param path - Path with mixed separators * @returns Path with consistent separators * * @example * ```typescript * // On Windows: * normalizePath('foo/bar\\baz'); // 'foo\\bar\\baz' * // On macOS/Linux: * normalizePath('foo/bar\\baz'); // 'foo/bar/baz' * ``` */ export declare function normalizePath(path: string): string; //# sourceMappingURL=platform.d.ts.map