Skip to content

`fs.unlink()` that _won't_ throw if the file is missing + other outcome-aware Node.js "fs" functions

License

Notifications You must be signed in to change notification settings

jokeyrhyme/idempotent-fs.js

Repository files navigation

idempotent-fs.js npm AppVeyor Status Travis CI Status

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

mkdir() and 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

rmdir() and 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!

unlink() and 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

About

`fs.unlink()` that _won't_ throw if the file is missing + other outcome-aware Node.js "fs" functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published