Closed iamchucky closed 7 years ago
Hi @iamchucky,
Can you show me an example that reproduces the error? There are various cases on the test suite where we use the .set()
function without options
(i.e. https://github.com/electron-userland/electron-json-storage/blob/master/tests/storage.spec.js#L198), but maybe I'm missing something?
I was not passing callback
either:
storage.set('settings', data);
example like above would work before 3.2.0 but throws error with 3.2.0
But now I realize that I should probably pass the callback function in as it is a required argument according to the documentation.
Ah, that makes sense. I think it should still be easy to fix. I'll prepare a PR later today.
@iamchucky Can you give https://github.com/electron-userland/electron-json-storage/pull/93 a go?
Check v4.0.1
I don't think #93 fixes this particular issue, when call storage.set('settings', data);
without both options
and callback
, options
is undefined
, therefore throws at https://github.com/electron-userland/electron-json-storage/blob/8c0519c0ae786c78f590a26d066205d39acf48e7/lib/storage.js#L269
Uncaught Exception:
TypeError: Cannot read property 'dataPath' of undefined
at Object.exports.set
Good point. What about v4.0.2?
Due to the changes in v3.2.0, there are bugs when calling
storage.set(key, json, [options], callback)
withoutoptions
It throws error when trying to access
options.dataPath
at https://github.com/electron-userland/electron-json-storage/blob/master/lib/storage.js#L256I think we need to ensure
options
is set to{}
at https://github.com/electron-userland/electron-json-storage/blob/master/lib/storage.js#L251 and make sure all other similar methods do the same thing, like .get and .has .remove .clear