UNPKG

fs-access-sync-compat

Version:

fs.accessSync ponyfill for older versions of Node.js

1 lines 920 B
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/compat/fs-access-sync-compat/src/index.ts"],"sourcesContent":["import fs from 'fs';\n\nfunction accessError(fullPath) {\n const err = new Error(`ENOENT: no such file or directory, access '${fullPath}'`) as NodeJS.ErrnoException;\n err.code = 'ENOENT';\n err.errno = -2;\n return err;\n}\n\nexport default (fullPath: string): NodeJS.ErrnoException | null => {\n try {\n fs.statSync(fullPath);\n return null;\n } catch (_err) {\n throw accessError(fullPath);\n }\n};\n"],"names":["accessError","fullPath","err","Error","code","errno","fs","statSync","_err"],"mappings":";;;;+BASA;;;eAAA;;;yDATe;;;;;;AAEf,SAASA,YAAYC,QAAQ;IAC3B,IAAMC,MAAM,IAAIC,MAAM,AAAC,8CAAsD,OAATF,UAAS;IAC7EC,IAAIE,IAAI,GAAG;IACXF,IAAIG,KAAK,GAAG,CAAC;IACb,OAAOH;AACT;IAEA,WAAe,SAACD;IACd,IAAI;QACFK,WAAE,CAACC,QAAQ,CAACN;QACZ,OAAO;IACT,EAAE,OAAOO,MAAM;QACb,MAAMR,YAAYC;IACpB;AACF"}