Refactor ZenFsAdapter to be lean and slick #4
+39
−178
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
Refactored the
ZenFsAdapterfrom 186 lines to 47 lines (75% reduction) by delegating tozenfs.fs.promisesinstead of manually wrapping sync methods. The adapter now only provides the minimal glue needed for just-bash compatibility:resolvePath()andgetAllPaths()which are just-bash-specific methodsRemoved custom type definitions, manual recursive
cpimplementation, and theensureParentDirshelper.Review & Testing Checklist for Human
ensureParentDirsremoval is acceptable: The old adapter auto-created parent directories on write operations. The new adapter does not - tests work because they use explicitmkdir -p. Confirm this behavioral change is intentional for the demo.rm --force. The new one delegates directly tofs.promises.rm. Verify edge cases still work as expected.IFileSystem- it relies on duck typing. Run through the demo scenarios to ensure all operations work.Test plan:
All 9 tests should pass, demonstrating write-via-bash/read-via-zenfs and vice versa.
Notes
The
getAllPaths()method still uses sync methods (readdirSync,lstatSync) since it returnsstring[]synchronously - this is required by just-bash's interface for glob matching.Link to Devin run: https://app.devin.ai/sessions/e5a59ab234c5481e817dad43a74cfc6e
Requested by: Dan Lynch (@pyramation)