Reputation: 1491
I have a file named file.json
in the /assets
directory and some of its subdirectories as well. Is there a way that I can search the assets
directory and read each of the file.json
file using the fs.readFileSync
method at once?
Upvotes: 0
Views: 277
Reputation: 14395
Not sure if you can do it synch, yet, you can use glob and stream-concat-files. Note the the concat by default is to a file but you can stream it to a a string buffer writeable stream.
glob('asset/**/file.json', function(err, files){concatFiles(files, 'concat.json', function(err){})});
Upvotes: 1