Skip to content
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

write an empty array to a json file logs an incorrect warning #77

Closed
1wheel opened this issue Aug 31, 2018 · 6 comments
Closed

write an empty array to a json file logs an incorrect warning #77

1wheel opened this issue Aug 31, 2018 · 6 comments

Comments

@1wheel
Copy link

1wheel commented Aug 31, 2018

io.writeDataSync('test.json', [])

[indian-ocean] Warning: You didn't pass any data to write for file: `test.json`. Writing out an empty file...

test.json is written out correctly:

[]
@mhkeller
Copy link
Owner

Do you think it should say "Writing out an empty array" or that it shouldn't' issue a warning in this scenario? I've found it useful to know if my length is zero sometimes so I would probably lean toward changing it to being accurate that it's writing a zero-length array but curious to hear other ideas!

I'm not sure if adding some logging level would make sense...

@1wheel
Copy link
Author

1wheel commented Aug 31, 2018

It was cluttering up papertrail logs; in this case I did want [] to be written.

Maybe a muteWarnings option?

@mhkeller
Copy link
Owner

Should it be a global setting like io.settings({muteWarnings: true}), on the call level io.writeDataSync(filePath, [], {muteWarnings: true}) or BOTH?

@mhkeller
Copy link
Owner

I can do on the call for now. Maybe something like {verbose: <Boolean>}

@1wheel
Copy link
Author

1wheel commented Aug 31, 2018

call seems good!

@mhkeller
Copy link
Owner

mhkeller commented Sep 1, 2018

verbose: false is now an option in writeData and writeDataSync: https://github.com/mhkeller/indian-ocean/blob/master/CHANGELOG.md#310

@mhkeller mhkeller closed this as completed Sep 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants