add: parse function add (contents !== '' ) #436
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
现在我有一个情况是,我用 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?
#411