Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outputFile() - ability to write data in appending mode #53

Closed
murindwaz opened this issue Mar 23, 2014 · 3 comments
Closed

outputFile() - ability to write data in appending mode #53

murindwaz opened this issue Mar 23, 2014 · 3 comments

Comments

@murindwaz
Copy link

Is there a way to support this functionality? say { append : true }
fs.outputFile(file, "hello!", function(err) {

}, { append : true });

@jprichardson
Copy link
Owner

No there isn't a way. I'm not sure that I'd like to support this. As then to keep consistency, I'd need to add {append: true} to other file write methods. You can accomplish what you want by creating the file and then appending where you need...

var fs = require('fs-extra');

var file = '/some/file/data.txt';
var data = // some data
fs.outputFile(file, data, function(err) { //creates directory structure if doesn't exist
  if (err) return console.error(err);

  /*** modify data ***/

  fs.appendFile(file, data, callback);
});

I'm going to leave this open to think about it as v0.9 is going to have some changes.

@jprichardson
Copy link
Owner

Decided against this. Previous code snippet is suggested alternative.

@kirkstrobeck
Copy link

^ Doesn’t work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants