function checkIsDir(filePath) {
  try {
    return fs.lstatSync(filePath).isDirectory();
  } catch {
    return filePath.endsWith(path.sep);
  }
}
Synchronously check if path is a directory. Tolerant to errors like ENOENT.

@param {string} filePath