Skip to content

Commit

Permalink
Write files atomically
Browse files Browse the repository at this point in the history
Fixes #127.
  • Loading branch information
kevva committed Oct 20, 2014
1 parent b57e1d3 commit c3b4989
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ var _ = require('lodash');
var date = require('easydate');
var each = require('each-async');
var fileUrl = require('file-url');
var fsWriteStreamAtomic = require('fs-write-stream-atomic');
var getRes = require('get-res');
var logSymbols = require('log-symbols');
var memoize = require('memoize-async');
Expand Down Expand Up @@ -99,7 +100,7 @@ exports.save = function (streams, cb) {
}

var dest = path.join(this.dest(), stream.filename);
var pipe = stream.pipe(fs.createWriteStream(dest));
var pipe = stream.pipe(fsWriteStreamAtomic(dest));

stream.on('warn', this.emit.bind(this, 'warn'));
stream.on('error', next);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"easydate": "^1.0.1",
"es5-shim": "^4.0.3",
"file-url": "^1.0.0",
"fs-write-stream-atomic": "^1.0.2",
"get-res": "^0.2.1",
"get-stdin": "^3.0.0",
"lodash": "^2.4.1",
Expand Down

0 comments on commit c3b4989

Please sign in to comment.