jaredwray / flat-cache

A stupidly simple key/value storage using files to persist the data
MIT License
165 stars 30 forks source link

Replace write with combination of mkdir and writeFile #49

Closed TrySound closed 4 years ago

TrySound commented 4 years ago

Node v10 introduced a great "recursive" option for mkdir which allows to get rid from mkdirp package and easily rewrite "write" package usage with two function calls.

https://nodejs.org/api/fs.html#fs_fs_mkdir_path_options_callback

TrySound commented 4 years ago

cc @royriojas

royriojas commented 4 years ago

hi @TrySound very nice!

But can we do this by moving the mkdirp lib to optional dependencies? trying first to use the new method and only in case of failure attempt to use mkdirp, just to keep backwards compatibility?

If not, we would have to consider releasing this as a major upgrade I think, but indeed very nice

TrySound commented 4 years ago

I'm not sure optional dependencies can help here. Major bump is safer solution IMO.

realityking commented 4 years ago

@royriojas It'd be nice to get a new major version with this change for less dependencies

Note that eslint already requires Node 10.12 as well so this would slot right in.

royriojas commented 4 years ago

Will check today which version is using eslint and align. I've been very busy lately but I will try to release a new version without these deps

realityking commented 4 years ago

Thank you @royriojas!