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 evoking fs.readJson:
/path/node_modules/jsonfile/index.js:19
callback(null, obj)
^
TypeError: undefined is not a function
at /path/node_modules/jsonfile/index.js:19:5
at fs.js:334:14
at FSReqWrap.oncomplete (fs.js:95:15)
On the other hand, using var fs = require('fs') and later fs.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 that fs-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.
It's because promsifyAll appends Async to the method names.
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)
})
https://github.com/petkaantonov/bluebird/blob/master/API.md#promisepromisifyallobject-target--object-options---object
Thank you for enlightening me.
Lesson learned: RTFM.
It's ok, we've all been there :)
Most helpful comment
It's because
promsifyAllappendsAsyncto the method names.See this snippet: