yeoman / configstore

Easily load and persist config without having to think about where and how
BSD 2-Clause "Simplified" License
868 stars 57 forks source link

Lazy directory / file create #56

Closed Jason3S closed 6 years ago

Jason3S commented 7 years ago

I noticed that configstore creates the directory and file on read.

Would you be interested in adding an option that allowed for file creation at write time if it doesn't exist?

I had some user complaining about files being written when they hadn't made any changes.

sindresorhus commented 7 years ago

I had some user complaining about files being written when they hadn't made any changes.

How would they even notice? It's not written in a location users usually look at. And why is it a problem? You're going to write to that directory at some point regardless. I'm just trying to understand your use-case.

Jason3S commented 7 years ago

Our use case is a bit different. If the global setting exists, then read it and merge it with the local settings. Related Issue is about how the file was written when it wasn't ask for.

I can do a pull request if this helps.

The idea is to add a "lazy" option and only create on write.

sindresorhus commented 7 years ago

Not really interested in an option for this obscure use-case, but I guess we could remove https://github.com/yeoman/configstore/blob/35d46bb6a37a17d5ff69896b13ea7c322728e54f/index.js#L33 as it seems moot since we already create the directory on write.

Jason3S commented 7 years ago

Excellent!! That works perfectly!

kevva commented 7 years ago

@Jason3S, PR welcome :).