Add bounded isEmptyDir checks - #1085
Draft
Victor-Su-Ortiz wants to merge 1 commit into
Draft
Victor-Su-Ortiz wants to merge 1 commit into
Victor-Su-Ortiz wants to merge 1 commit into
Conversation
Collaborator
|
Please undraft once you've reviewed this yourself and this PR is ready for review. From a quick cursory look, this PR could use some cleanup. Going forward, I'd prefer if PRs were opened only after you've given the code a human review. But thanks for being transparent and upfront about the AI usage and status of the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1037.
Add
isEmptyDir(promise/callback) andisEmptyDirSync, exported through the CommonJS and ESM entry points. Both useopendirand read a single entry, then close the handle. Filesystem errors are preserved, including a read error if closing also fails.Includes API documentation and tests for empty/nonempty directories, missing paths, files, symlinks, bounded reads, and cleanup.
Verification
npm test: lint, 760 CommonJS tests, and ESM tests pass; 8 existing tests pending. Cross-device tests were not enabled.git diff --check: passed.Verified locally on macOS; other platforms remain for CI.
AI assistance
Implementation and initial tests were produced through OpenCode using
opencode/space-bunny-free(Space Bunny). Codex reviewed the diff and independently ran the checks above. This draft has not received human code review.