prepare-write
Prepare for writing a file to the given path – create ancestor directories and verify no directory exists in the path
const existsSync = ;const prepareWrite = ; async { ; //=> false await ; ; //=> true ; //=> true ; //=> true ; //=> false};
Installation
npm install prepare-write
API
const prepareWrite = ;
prepareWrite(path)
path: string
(directory path)
Return: Promise<string | null>
It ensures you can soon write a file to the given path by:
- Creating ancestor directories if they don't exist
- Checking if no directory already exists in the path
async { // a directory /foo doesn't exist await ; // a directory /foo/bar now exists await ; // Error: Tried to create a file as /foo/bar, but a directory with the same name already exists.};
License
ISC License © 2017 - 2019 Watanabe Shinnosuke