node-archiver icon indicating copy to clipboard operation
node-archiver copied to clipboard

How can i know that the stream is finished?

Open johann1301s opened this issue 2 years ago • 2 comments

It says in the example docs that after calling archive.finalize()

'close', 'end' or 'finish' may be fired right after calling this method so register to them beforehand


Ok, so they may fire, how can i guaranty that they will fire? And which one? It specifies or, but no explanation to which event?

johann1301s avatar Jun 16 '22 15:06 johann1301s

Was looking at the same event, 'finish' was emitted in archiver v1 but since I updated this library, nothing clearely shows that. I think the doc is outdated because I cannot seem to find any emit('finish') inside the library code.

A solution might be to call whatever you want to do after archive.finalize() (for a build script in my case)

Looking for more clarification from the authors :)

MrBenHacker avatar Jun 20 '22 10:06 MrBenHacker

I think there is a confusion here, the documentation say that MAY fire after calling the finalize, but it's talking that can be done instantly or a bit later. Not that are not going to be fired.

The events don't appear because those are stream.Writable events from node: https://nodejs.org/api/stream.html#class-streamwritable

sebastian-greco avatar Aug 19 '22 13:08 sebastian-greco