yeoman/configstore

Lazy directory / file create

Jason3S opened this issue · 5 comments

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.

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.

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.

Not really interested in an option for this obscure use-case, but I guess we could remove

makeDir.sync(path.dirname(this.path), makeDirOptions);
as it seems moot since we already create the directory on write.

Excellent!! That works perfectly!

kevva commented

@Jason3S, PR welcome :).