Closed localjo closed 9 years ago
Thanks for the feedback, @josiahsprague. But the native require()
also throws an error if a file or module doesn't exist, so it feels like the right thing to do here also. (And I think in other cases, failing fast with an error would have been helpful to spot a bug sooner.)
The good news is that the error message is descriptive and accurate, at least to me. Did you think so too?
Closing since no response, and this feels like the right thing to do. Feel free to chime in if you still disagree. =)
I was using requireDir to include optional files into my project. Over the course of time, all of those optional files ended up getting removed, so the directory itself was lost by git, and then my project suddenly stopped working. Took me awhile to track down the cause. In my case, adding a
.gitkeep
to the directory is an acceptable solution. But, I propose that there be some sort of error handling if a directory doesn't exist. Maybe return an empty object or null instead of completely blowing up. Example;