Filendir
Write a file given a full path. Create the missing directories if necessary.
API
Filendir exposes an asynchronous and a synchronous write method.
It also exposes mkdirp
to create directories only, if you need it.
filendir versions node support
- 1.x for nodejs v4 to v9
- 2.x for nodejs v10 to now
Synchronous write
- filendir.ws (shorthand)
- filendir.writeFileSync
Apart from creating the missing directories,
it has the same behaviour and interface than node fs.writeFileSync
.
// signaturefilendir
See fs.writeFileSync in Node.js site
Example
var path = var filendir = var filename = pathvar content = 'Hello World' filendir
Asynchronous write
- filendir.wa (shorthand)
- filendir.writeFile
Apart from creating the missing directories,
it has the same behaviour and interface than node fs.writeFile
.
Extra from fs.writefile: you can use promises
// callback usefilendir
// with promiseawait filendir
See fs.writeFile in Node.js site
Example
var path = var filendir = var filename = pathvar content = 'Hello World' filendir
filendir.mkdirp
Credits to Substack. Would have been harder to do this without it.