-
Notifications
You must be signed in to change notification settings - Fork 932
chore: refactor envinfo #1025
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
chore: refactor envinfo #1025
Conversation
thymikee
left a comment
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.
This is great! Let's iterate on the typings so we don't have to cast
|
|
||
| beforeAll(async () => { | ||
| environmentInfo = await getEnvironmentInfo(); | ||
| environmentInfo = (await getEnvironmentInfo()) as EnvironmentInfo; |
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.
This is not good. Let's type getEnvironmentInfo properly so it returns correct type based on the arguments
2773aba to
6fb73a2
Compare
packages/cli/src/tools/envinfo.ts
Outdated
| * If set to `false`, it will be a `string`. | ||
| */ | ||
| async function getEnvironmentInfo(): Promise<EnvironmentInfo>; | ||
| async function getEnvironmentInfo(json: boolean): Promise<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.
I'm not super thrilled with this but haven't come up with a better idea yet.
getEnvironmentInfo()return type will beEnvironmentInfo✔getEnvironmentInfo(false)return type will be astring✔getEnvironmentInfo(true)return type will be astring❌
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.
Got it finally right 😊
6fb73a2 to
b1b2623
Compare
packages/cli/src/tools/envinfo.ts
Outdated
| ): Promise<string | EnvironmentInfo> { | ||
| const options = json | ||
| ? {json: true, showNotFound: true} | ||
| : {json: false, showNotFound: true}; |
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.
We can have a single object and use json value because it's already boolean
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.
Done!
b1b2623 to
538041a
Compare
packages/cli/src/tools/envinfo.ts
Outdated
| async function getEnvironmentInfo( | ||
| json = true, | ||
| ): Promise<string | EnvironmentInfo> { | ||
| const options = {json, showNotFound: json}; |
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.
I thought we always want to show Not Found?
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.
I'm all for always showing Not Found. Is just that in one place it was explicit and in the other not (and I think the default is false).
I'll update the PR
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.
Updated
8af0ba9 to
2bd4513
Compare
|
Thanks! |
I only see a single call site being updated as a part of this PR. Are there any other places we haven't refactored? |
|
This was the only one and it also got out of sync with options, so it's an improvement already. |
|
The other call used |
Summary:
While working on #976 I saw that I needed to modify the properties requested to
envinfoand that it was being accessed in a couple different places with different configurations.This PR changes that to use a single point (and single configuration) to get the info.