node package manager
Stop writing boring code. Discover, share, and reuse within your team. Create a free org »

safe-write-stream

Safe Write Stream

Like fs.createWriteStream, but it will create the needed directories before trying to create the file.

Install

npm install safe-write-stream

Usage

var safeWriteStream = require('safe-write-stream');
 
fs.createReadStream('file.txt')
  .pipe(safeWriteStream(__dirname+'/these/will/be/created/file.txt'))

Parameters

See the fs.createWriteStream docs.