Fix Errno::EISDIR

Sometime, a directory is named like a file. Like `typeahead.js`, and
ruby does like opening a directory while thinking it's a file.

Signed-off-by: chatgris <jboyer@af83.com>