Revert "Use fs.stat to check if path is file or dir"

This reverts commit 072063fb66a2fd7c0bcc4bbc6c705b25e9753c49.