fix: lookupFiles() now returns string[] for direct file paths#5941
Conversation
Previously, when a file path was passed directly (not a glob or directory), the function returned a bare string, violating its documented return type of string[]. Closes mochajs#5940
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR fixes a return-type inconsistency in Mocha’s CLI file-discovery helper lookupFiles(): when an existing direct file path is provided (not a glob or directory), it now returns a string[] (singleton array) instead of a bare string, matching the function’s documented JSDoc return type.
Changes:
- Adjusted the direct-filepath short-circuit in
lookupFiles()to return[filepath]instead offilepath.
🤔🤔🤔 |
|
@JoshuaKGoldberg Happy to adjust if there’s an alternative way to handle this. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5941 +/- ##
=======================================
Coverage 80.85% 80.85%
=======================================
Files 64 64
Lines 4566 4566
Branches 977 958 -19
=======================================
Hits 3692 3692
Misses 874 874 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Unrelated integration test flake, I believe. |
PR Checklist
status: accepting prsOverview
This PR addresses a return-type inconsistency in
lookupFiles(). As documented in its JSDoc, the function should returnstring[], but it was returning a barestringwhen a direct file path was provided.Changes
lib/cli/lookup-files.mjsto wrap direct file path returns in an array.Verified locally using smoke tests and by confirming
Array.isArray()on the return value for direct file paths.