UNPKG

next-zombie

Version:

Fix ENOENT _buildManifest.js.tmp error. Auto-restart Next.js Turbopack dev server on crash. Supports Next.js 13.4+.

89 lines (80 loc) 2.46 kB
/** * Error patterns that trigger auto-restart. * Only matches Turbopack internal errors, not user code errors. */ export const PATTERNS: RegExp[]; /** * Pattern for detecting port conflict errors (EADDRINUSE). */ export const PORT_PATTERN: RegExp; /** * Detects the package manager from lockfile. * @param cwd - Working directory to check (defaults to process.cwd()) * @returns Detected package manager * * @example * ```ts * detectPM() // 'pnpm' if pnpm-lock.yaml exists * detectPM('/path/to/project') // Check specific directory * ``` */ export function detectPM(cwd?: string): 'npm' | 'pnpm' | 'yarn' | 'bun'; /** * Tests if text matches any Turbopack error pattern. * @param text - Text to check (usually stdout/stderr output) * @returns true if text matches a known error pattern * * @example * ```ts * matchError('ENOENT: .next/cache/foo') // true * matchError('SyntaxError: ...') // false (user code error) * ``` */ export function matchError(text: string): boolean; /** * Tests if text contains a port conflict error (EADDRINUSE). * @param text - Text to check * @returns true if port conflict detected */ export function matchPortError(text: string): boolean; /** * Extracts the port number from an EADDRINUSE error message. * @param text - Error text containing port info * @returns Port number or null if not found */ export function extractPort(text: string): number | null; /** * Parsed CLI arguments. */ export interface ParsedArgs { /** Script name to run (defaults to 'dev') */ script: string; /** Extra arguments to pass to the script */ extra: string[]; } /** * Parses CLI arguments into script name and extra args. * @param args - CLI arguments (without node and script path) * @returns Parsed arguments object * * @example * ```ts * parseArgs([]) // { script: 'dev', extra: [] } * parseArgs(['build']) // { script: 'build', extra: [] } * parseArgs(['dev', '--port', '3001']) // { script: 'dev', extra: ['--port', '3001'] } * ``` */ export function parseArgs(args: string[]): ParsedArgs; /** * Builds command arguments for spawn. * @param script - Script name to run * @param extra - Extra arguments to pass * @returns Array of arguments for spawn * * @example * ```ts * buildArgs('dev', []) // ['run', 'dev'] * buildArgs('dev', ['--port', '3001']) // ['run', 'dev', '--', '--port', '3001'] * ``` */ export function buildArgs(script: string, extra: string[]): string[];