szwacz/fs-jetpack

existsAsync is broken

chrisgbk opened this issue · 1 comments

The fs library is promisified, but this function still calls it like it was the callback version.

Patch:

const existsAsync = path => {
  return new Promise((resolve, reject) => {
    fs.stat(path).then( stat => {
      if (stat.isDirectory()) {
        resolve("dir");
      } else if (stat.isFile()) {
        resolve("file");
      } else {
        resolve("other");
      }
    }).catch( err => {
      if (err.code === "ENOENT") {
        resolve(false);
      } else {
        reject(err);
      }
    });
  });
};

Good catch! Fixed in v1.3.1