node.js - End of multiple streams (stream inside loop) -


im working on project , have compress several directories, , use compressed files call function. that, i'm using https://github.com/npm/fstream , https://github.com/npm/node-tar libraries.

 var fstreamr = require('fstream').reader;  var fstreamw = require('fstream').writer;  var tar = require('tar');   (var comp in components){       // in order build images docker api, directory      // containing dockerfile , code must compressed      // tar.      var fr = fstreamr({'path':components[comp],'type':'directory'})      var fw = fstreamw({'path':'../../'+comp+'.tar'})      fr       .pipe(tar.pack())       .pipe(fw)      fw.on('finish',function(){           //do      }) } 

so comp changes in each iteration , create new tar file. problem need tar completed before calling function uses it.

i have 2 issues here. first one: callback @ event listener event 'finish' never called.

the second one: if working, callback launched value of comp corresponding for iteration in event listener called?.

i appreciate suggestions or other ideas work around problem. in advanced.

in regards first issue, try listening fw.on('close') instead. looks source may emitting close , not finish.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -