Have [_tarballFromResolved] return a Promise<Stream> rather than a Stream
Opened this issue · 0 comments
Right now the [_tarballFromResolved]
methods on all the Fetcher subclasses return a Minipass stream. Then, all of them do some kind of async action, and pipe into that Minipass stream once they have data.
One impact of this is that pacote.tarball.file('file:.', './dir.tgz')
will include an empty dir.tgz
file in the tarball, because it starts piping to the target location before the npm-packlist
command runs and creates the list of files to add in the tar.c()
stream.
The change to lib/fetcher.js
is small, but of course then all the other methods that implement [_tarballFromResolved]
will have to be updated to return a Promise instead of a stream directly.
Here's a quick and dirty untested patch to make the fetchers all switch over to returning a Promise rather than a stream. Doesn't look too bad, and while it makes the code calling _tarballFromResolved slightly more complicated, it really reduces the complexity of the implementations.
https://gist.github.com/isaacs/2650b74c43637a5892d945cfc551d2d0
cc: @claudiahdz