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

refactor: clean up fs.readFile usage #3966

Merged
merged 4 commits into from
Dec 8, 2020

Conversation

jedwards1211
Copy link
Contributor

@jedwards1211 jedwards1211 commented Dec 4, 2020

The way fs.readFile was being used looked like a code smell, and sure enough, the way it was being mocked would cause surprise errors for anyone who adds idiomatic fs-extra calls in new or updated tests. Pass encoding ('utf8', the default) to get readFile to resolve to a string instead of a buffer, and use readJson where applicable. Update fs mocks to behave a bit more like fs-extra in this regard (though I'm not sure it would be possible to support all options, but we can at least support encoding string as second argument).

@jedwards1211 jedwards1211 changed the title feat: add mqtt definitions refactor: clean up fs.readFile usage Dec 4, 2020
@jedwards1211 jedwards1211 reopened this Dec 4, 2020
@AndrewSouthpaw
Copy link
Contributor

@gantoine or @villesau if either of you have poked at the CLI lately?

@AndrewSouthpaw
Copy link
Contributor

is this related to #3965 ?

@jedwards1211
Copy link
Contributor Author

jedwards1211 commented Dec 8, 2020

@AndrewSouthpaw it doesn't fix that issue AFAIK. I just noticed the weird fs calls while reporting that issue, and figured why not make them more normal.

@AndrewSouthpaw AndrewSouthpaw merged commit 11f725a into flow-typed:master Dec 8, 2020
@AndrewSouthpaw
Copy link
Contributor

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

3 participants