Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Have [_tarballFromResolved] return a Promise<Stream> rather than a Stream #35

Open
isaacs opened this issue Mar 13, 2020 · 0 comments
Open

Comments

@isaacs
Copy link
Contributor

isaacs commented Mar 13, 2020

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant