iTonyYo/gitin

View on GitHub
src/utilities/fileExists.js

Summary

Maintainability
A
55 mins
Test Coverage
/**
 * TODO: 待 `fs Promises` 接口稳定后使用
 * 参见 https://goo.gl/xtwgwG
 */
import pStat from './pStat';

const fileExists = async (path) => {
  try {
    const stat = await pStat(path);
    return stat.isFile();
  } catch (error) {
    return false;
  }
};

export default fileExists;