isPathNotFoundError.js 331 B

123456789101112
  1. 'use strict';
  2. const util = require('util');
  3. /**
  4. * @param {unknown} error
  5. * @returns {error is NodeJS.ErrnoException}
  6. */
  7. module.exports = function isPathNotFoundError(error) {
  8. // @ts-expect-error -- TS2339: Property 'code' does not exist on type 'Error'.
  9. return util.types.isNativeError(error) && error.code === 'ENOENT';
  10. };