web-ext
Version: 
A command line tool to help build, run, and test web extensions
20 lines (19 loc) • 495 B
JavaScript
import fs from 'fs/promises';
import { onlyErrorsWithCode } from '../errors.js';
/*
 * Resolves true if the path is a readable directory.
 *
 * Usage:
 *
 * isDirectory('/some/path')
 *  .then((dirExists) => {
 *    // dirExists will be true or false.
 *  });
 *
 * */
export default function isDirectory(path) {
  return fs.stat(path).then(stats => stats.isDirectory()).catch(onlyErrorsWithCode(['ENOENT', 'ENOTDIR'], () => {
    return false;
  }));
}
//# sourceMappingURL=is-directory.js.map