Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

await tmp.dir() returns a string now. #29

Closed
davidmurdoch opened this issue May 14, 2019 · 2 comments · Fixed by #30
Closed

await tmp.dir() returns a string now. #29

davidmurdoch opened this issue May 14, 2019 · 2 comments · Fixed by #30

Comments

@davidmurdoch
Copy link

tmp-promise/index.js

Lines 25 to 30 in 6bd19f9

module.exports.dir = promisify(
(options, cb) => tmp.dir(
options,
(err, path, cleanup) => cb(err, {path, cleanup})
)
);

I think this is what is happening here is this:

promisify will always pass its promise-resolving callback function after the caller's last argument. Calling tmp-promise's tmp.dir without an options argument will cause promisify to pass its callback function as the first arg (options here), since the first arg is also the final arg.

When tmp.dir is given a function as it's first arg, as is done here when options is not provided, it uses that argument as the callback function.

This means the callback function tmp-promise provides as the second argument to tmp.dir is never called.

@benjamingr
Copy link
Owner

Good catch, I have unpublished 2.x in the meantime since the regression is big enough in my opinion to warrant that on holiday but I've not reverted the code in master.

I can take a look when I'm back from DevDays on doing a quick fix.

I thought we had a test for this but apparently we don't - that's entirely unacceptable and is my fault, I will write one when I get back.

PR for either (and hopefully both) of those things welcome :)

cc @paulmelnikow

@paulmelnikow
Copy link
Collaborator

I'll see if I can push a test!

paulmelnikow added a commit to paulmelnikow/tmp-promise that referenced this issue May 14, 2019
paulmelnikow added a commit to paulmelnikow/tmp-promise that referenced this issue May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants