$ show jprichardson/node-fs-extra
fs-extra is a Node.js library that extends the native `fs` module with additional file system operations and promise support. It provides drop-in replacement for `fs` with methods like `copy`, `move`, `remove`, `ensureDir`, `outputFile`, `readJson`, `writeJson`, and more. The library uses `graceful-fs` to prevent EMFILE errors and `universalify` to add promise support to all async methods. It supports both CommonJS and ESM imports. The codebase is well-structured with separate modules for each feature (copy, move, ensure, json, mkdirs, etc.) and comprehensive test coverage. It handles edge cases such as symlinks, permissions, timestamps, cross-device moves, and case-insensitive file systems. The library is actively maintained with frequent releases and supports Node.js 14+.
The LLM identified 4 files worth highlighting for reuse:
Provides `asyncIteratorConcurrentProcess` function that processes items from an async iterator in parallel, collecting errors and rethrowing them after all operations complete. This is a reusable pattern for handling concurrent async operations with proper error propagation, avoiding unhandled promise rejections. It can be extracted and used in any project that needs to process async iterables concurrently.
Implements `utimesMillis` and `utimesMillisSync` for setting file access and modification times with millisecond precision. It properly handles file descriptor cleanup even when errors occur, ensuring no resource leaks. The pattern of opening a file, performing an operation, and closing in a finally block with error aggregation is a robust pattern for file descriptor management that can be reused in other file system utilities.
Resolves the appropriate source path for creating a symlink by checking multiple possibilities: absolute paths, relative-to-symlink paths, and relative-to-cwd paths. It returns both `toCwd` and `toDst` paths, allowing the caller to choose the best option. This is a non-trivial algorithm that handles edge cases in symlink creation and can be reused in any project that needs to create symlinks with smart path resolution.
Determines the symlink type ('file' or 'dir) based on the source path's stat, with a fallback to 'file' if the source does not exist. This is a simple but essential utility for creating symlinks with the correct type on Windows. The pattern of checking the source type and providing a sensible default is reusable for any cross-platform symlink creation.