Node: How to wait until a file is completed before processing it?

后端 未结 2 659
醉话见心 2021-02-20 17:39

My Problem is that I can not be sure when a file has been successfully written to and the file has been closed. Consider the following case:

var fs = require(\'f         

  • 2021-02-20 18:09

    Do your file's post-processing in the writeable stream's close event:

    outs.on('close', function() {
      <<spawn your process>>

    Also, no need for the destroySoon after the end, they are one and the same.

    0 讨论(0)
  • 2021-02-20 18:10

    Check out – I don't know why it's not written into the Writable core but this should do the trick.

    Also, there's a discussion addressing this on GitHub

    0 讨论(0)