fs-access-sync-compat
Version:
fs.accessSync ponyfill for older versions of Node.js
16 lines (15 loc) • 363 B
JavaScript
import fs from 'fs';
function accessError(fullPath) {
const err = new Error(`ENOENT: no such file or directory, access '${fullPath}'`);
err.code = 'ENOENT';
err.errno = -2;
return err;
}
export default ((fullPath)=>{
try {
fs.statSync(fullPath);
return null;
} catch (_err) {
throw accessError(fullPath);
}
});