Created
September 4, 2017 14:09
-
-
Save Quidge/59427b336fa985d8ae33f00cf99379a3 to your computer and use it in GitHub Desktop.
fs.createWriteStream example from the command line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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