code: function isDirectory(filePath) {
    if (!isExist(filePath)) return false;
    try {
      const stat = fs.statSync(filePath);
      return stat.isDirectory();
    } catch (e) {
      return false;
    }
  }
docs: check path is directory