findFileInDirectory was skipping index.js
Check that realpath didn't return false before attempting is_dir