npm

Need private packages and team management tools?Check out npm Orgs. »

filendir

1.0.2 • Public • Published

Filendir

Write a file given a full path. Create the missing directories if necessary.


js-standard-style Build Status

API

Filendir exposes an asynchronous and a synchronous write method.

It also exposes `mkdirp to create directories only, if you need it.

Synchronous write

  • filendir.ws (shorthand)
  • filendir.writeFileSync

Apart from creating the missing directories, it has the same behaviour and interface than node fs.writeFileSync.

// signature
filendir.writeFileSync(filename, data[, options])

See fs.writeFileSync in Node.js site

Example

var path = require('path')
var filendir = require('filendir')
var filename = path.join('let','s', 'nest','some','directories','myfile.txt')
var content = 'Hello World'
 
filendir.ws(filename, content)

Asynchronous write

  • filendir.wa (shorthand)
  • filendir.writeFile

Apart from creating the missing directories, it has the same behaviour and interface than node fs.writeFile.

// signature
filendir.writeFile(filename, data[, options], callback)

See fs.writeFile in Node.js site

Example

var path = require('path')
var filendir = require('filendir')
var filename = path.join('let','s', 'nest','some','directories','myfile.txt')
var content = 'Hello World'
 
filendir.wa(filename, content, function (err) {
  if (!err) {
    console.log('File written!')
  }
})

filendir.mkdirp

Credits to Substack. Would have been harder to do this without it.

See https://www.npmjs.org/package/mkdirp

install

npm i filendir

Downloadsweekly downloads

2,486

version

1.0.2

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability