Created
September 8, 2012 21:37
-
-
Save soldair/3679955 to your computer and use it in GitHub Desktop.
pause node walkdir, read a file into a write stream, then resume
This file contains hidden or 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
// walkdir ~0.0.5 | |
var fs = require('fs') | |
, walkdir = require('../walkdir') | |
// write all logs to the logs.cat file | |
, ws = fs.createWriteStream('logs.cat') | |
; | |
var em = walkdir('./'); | |
em.on('file',function(path,stat){ | |
if(path.indexOf('.log') != path.length-4) return; | |
em.pause(); | |
var rs = fs.createReadStream(path); | |
rs.on('end',function(){ | |
em.resume(); | |
}); | |
rs.on('data',function(buf){ | |
ws.write(buf); | |
}); | |
}); | |
em.on('end',function(){ | |
console.log('done!'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment