-
Notifications
You must be signed in to change notification settings - Fork 773
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
Promise.promisifyAll doesn't work for some methods #156
Comments
It's because See this snippet: var Promise = require('bluebird')
var fs = require('fs-extra')
var fsp = Promise.promisifyAll(fs)
fsp.readJsonAsync('./package.json')
.then(function (obj) {
console.dir(obj)
})
.catch(function (err) {
console.error(err)
}) |
Thank you for enlightening me. |
It's ok, we've all been there :) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there!
Since it is mentioned in the README that fs-extra's methods can be promisified with bluebird's promisifyAll method, I figured out that I should report the following: not all methods seem to be promisified correctly with that method.
As far as I can tell, .readJson is one such method.
Using
var fs = Promise.promisifyAll(require('fs-extra'))
yields the following error upon evokingfs.readJson
:On the other hand, using
var fs = require('fs')
and laterfs.readJson = Promise.promisify(fs.readJson)
works fine for me. I therefore suggest warning users that some methods need to be promisified individually in order to work, if others are able to reproduce this problem, that is. Note thatfs-extra-promise
is also affected by this.Note that I am using Promises in async/await functions with Babel, so there is a real possibility that those that are just using Promises with bluebird do not experience the same problem.
The text was updated successfully, but these errors were encountered: