Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

safe-readfile

tallesl932Fairdeprecated1.0.2

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

readFile that ignores ENOENT.

safe, readfile, enoent

readme

safe-readfile

A version of fs.readFile and fs.readFileSync that doesn't raise ENOENT.
Returns undefined if the file doesn't exist and '' if the file exists and it's empty.

Usage

$ npm install safe-readfile
(...)
$ node
> var safeReadFile = require('safe-readfile').readFile
undefined
> safeReadFile('nonexistent') // fs.readFile would throw ENOENT
undefined