nconf icon indicating copy to clipboard operation
nconf copied to clipboard

add: parse function add (contents !== '' )

Open huyunan opened this issue 6 months ago • 0 comments

现在我有一个情况是,我用 nconf 生成一个配置文件 config.json ,然后使用监听方法监听 config.json 的变化,重新生成配置。但是用户可能为了方便直接清空文件内容,而不是保留 "{}" 最外层大括号。但这就会有 parse 为空报错问题,所以加了个空判断,如果文件已经生成了,但是文件内容为空,默认设置为空对象。可以吗? Now I have a situation where I generate a configuration file named config.json using nconf, and then use the listening method to listen for changes in config.json and regenerate the configuration. However, users may directly clear the file content for convenience instead of keeping the outermost curly braces of "{}". However, this would lead to an error when parse is empty. Therefore, an empty judgment was added. If the file has been generated but its content is empty, the default setting is an empty object. Is it okay? https://github.com/indexzero/nconf/issues/411

huyunan avatar Jul 08 '25 05:07 huyunan