mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Implement Bun.rename() API that extends Node.js fs.promises.rename() with an optional third parameter for conflict resolution: - replace (default): Replace destination if it exists - swap: Atomically swap files/directories (Unix only, falls back on Windows) - no-replace: Fail if destination already exists Features: - Uses atomic operations (renameat, renameat2) for best performance - Cross-platform support with graceful Windows fallbacks - Async implementation using WorkPoolTask and proper promise handling - Comprehensive input validation and error handling - Full TypeScript definitions with detailed JSDoc - PathLike support (strings, Buffers, URLs) Implementation details: - Added to BunObject.zig with proper async patterns - Updated C++ bindings and hash tables - 32 comprehensive tests covering all modes and edge cases - Complete documentation with usage examples - Platform-aware behavior documented for Windows limitations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>