README
idempotent-fs.js
fs.unlink()
that won't throw if the file is missing + other outcome-aware Node.js "fs" functions
What is this?
We have taken inspiration from idempotent REST APIs.
The functions provided here intentionally mirror the "fs" module that Node.js provides, but will not throw errors under certain outcome-oriented conditions.
We've wrapped any asynchronous functions provided here with the wonderful pify,
you can use either Promise
-style or traditional callback-style.
Internally, we use graceful-fs instead of using the built-in "fs" module directly.
Usage
and mkdir()mkdirSync()
See the upstream mkdir()
and mkdirSync
"fs" functions in Node.js.
Changed: No "EEXIST" error. Trying to
mkdir()
a directory that already exists is not an error. Mission accomplished!Changed: internally uses mkdirp
and rmdir()rmdirSync()
See the upstream rmdir()
and rmdirSync
"fs" functions in Node.js.
- Changed: No "ENOENT" error. Trying to
rmdir()
a directory that is already gone is no longer an error. Mission accomplished!
and unlink()unlinkSync()
See the upstream unlink()
and unlinkSync
"fs" functions in Node.js.
- Changed: No "ENOENT" error. Trying to
unlink()
a file that is already gone is no longer an error. Mission accomplished!
Roadmap
mkdir()
should also test provided mode (if any)