Change to more robust file checking

The `isFilePath` function simply checked for the presence of a period in the output path. This isn't a reliable way to detect files vs. directories (directories can have periods in their names, and files don't have to).

This switches to using `fs.statSync` to check if `stat.isFile()` is true, which actually detects files vs. directories.
Merge pull request #2719 from davewasmer/patch-3

Change to more robust file checking