fix(cli): avoid ENOTDIR when scanning a single file - #148
Conversation
The automatic scanoss.json settings lookup called readdir directly on the scan target, crashing with ENOTDIR when the target was a single file instead of a directory. Now it stats the path first and resolves the parent directory for single files. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR fixes a bug where scanning a single file with ChangesSingle-File Scan Bug Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
scanoss-js scan <file>crashed withENOTDIRwhen the scan target was a single file instead of a directory:The automatic
scanoss.jsonsettings lookup (introduced in SP-1996) calledfs.promises.readdir()directly on the scan target without checking whether it was a directory, so single-file scans crashed before the scan even started.Changes
getSettingsFilePath()now stats the path first; for single files it looks for the defaultscanoss.jsonin the file's parent directory instead of callingreaddiron the file itself.helpers.spec.tswith 5 tests covering the settings lookup, including theENOTDIRregression case.Test plan
npm test— 177 passing (172 existing + 5 new)npm run build🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
scanoss-js scan <file>failed with anENOTDIRerror. The settings lookup now correctly resolves to the file's parent directory.Version