rmf
Remove a file or symbolic link without throwing an error when the target does not exist, as UNIX rm -f
does
const unlink = promises;const rmf = ; // file.txt does not exist async { await ; // will be rejected with Error: ENOENT: no such file or directory, unlink 'file.txt' await ; //=> won't be rejected};
This library helps removing temporary files generated by test scripts, as they would not exist before the first execution.
Installation
npm install rmf
API
const rmf = ;
rmf(filePath)
filePath: string
Buffer
Uint8Array
URL
Return: Promise<boolean>
It removes a file or symbolic link.
When it successfully remove the target, the Promise
will be resolved with true
. When the target doesn't exist, the Promise
will be resolved with false
.
When the operation fails with another reason, for example the target is a directory, the Promise
will be rejected.
async { // A file a.jpg exists, but b.jpg doesn't await ; //=> true await ; //=> false await ; // rejected with Error: EPERM: operation not permitted, unlink '/Users/shinnn/'};
License
ISC License © 2018 Shinnosuke Watanabe