all files / file-manager-js/lib/ exists.js

90% Statements 9/10
50% Branches 1/2
100% Functions 0/0
88.89% Lines 8/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24                  46× 25×   21× 21×            
/**
 * file-manager-js/exists
 * @copyright 2018 Eyas Ranjous <eyas.ranjous@gmail.com>
 * @license MIT
 */
 
const stat = require('./stat');
 
// checks if a file or dir exists
const exists = (fsStat) => {
  const statFn = stat(fsStat);
 
  return path => statFn(path)
    .then(() => true)
    .catch((error) => {
      Eif (error.code === 'ENOENT') {
        return false;
      }
      return Promise.reject(error);
    });
};
 
module.exports = exists;