Skip to content

Instantly share code, notes, and snippets.

@Quidge
Created September 4, 2017 14:09
Show Gist options
  • Save Quidge/59427b336fa985d8ae33f00cf99379a3 to your computer and use it in GitHub Desktop.
Save Quidge/59427b336fa985d8ae33f00cf99379a3 to your computer and use it in GitHub Desktop.
fs.createWriteStream example from the command line
var fs = require('fs');
process.stdin.resume();
process.stdin.setEncoding('utf8');
var stream = fs.createWriteStream(process.argv[2]);
process.stdin.on('data', function(text) {
if (text === 'quit\n') {
stream.end();
process.exit();
}
stream.write(text);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment