New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configFileMode
option
#158
Add configFileMode
option
#158
Conversation
source/types.ts
Outdated
|
||
@default 0o666 | ||
*/ | ||
mode: number | string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mode: number | string; | |
configFileMode: number; |
I'm aware the underlying API supports a string, but that's only for legacy reasons. I prefer to keep it simple.
source/types.ts
Outdated
@@ -137,6 +137,13 @@ export interface Options<T> { | |||
*/ | |||
clearInvalidConfig?: boolean; | |||
|
|||
/** | |||
The mode that will be used for the config file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linkify mode
to a website that explains what mode
is. Not every user is familiar with the concept.
source/types.ts
Outdated
@@ -137,6 +137,13 @@ export interface Options<T> { | |||
*/ | |||
clearInvalidConfig?: boolean; | |||
|
|||
/** | |||
The mode that will be used for the config file. | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs should explain when it would be useful. Most devs would not need this, and from experience, setting mode
can cause a lot of problems. For example, user run a tool with sudo
and then later not with sudo
and then the config file is not readable, etc. I did the mode thing in a different config library, and it caused endless of support requests.
For example, on macOS, conf
by default, stores the config in ~/Library/Preferences
, which is not world writable. So this would not be needed if you target only macOS.
You need to document it in the readme too. |
I'll make the changes requested, and the CI formatting fixes shortly. The only question I have is the proper destination for the The node documentation for Do you have any preferences for the level of detail in the explanation link for the |
I've pushed a change as a separate commit that does the following:
This is a separate commit to make it easy to see the changes from before, but I'm also happy to squash into a single commit before this is merged. |
This is a proposed implementation for #157. This adds a
mode
option, which is passed through to the underlying call tofs.writeFileSync
oratomically.writeFileSync
.The default mode here (
0o666
) is the default mode for bothfs.writeFileSync
andatomically.writeFileSync
so this should be a backwards-compatible change.