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

Add functionality that allows Clinic to get the issue category from Doctor #323

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

Conversation

ConorDavenport
Copy link
Contributor

@ConorDavenport ConorDavenport commented Apr 17, 2020

Added an issue member that allows clinic to print the recommended next step to the console.

See clinicjs/node-clinic#234 for Clinic implementation

@ConorDavenport ConorDavenport changed the title Print recommended next step to console Add a function that allows Clinic to get the issue category Apr 21, 2020
@ConorDavenport ConorDavenport marked this pull request as ready for review April 21, 2020 08:29
@ConorDavenport ConorDavenport changed the title Add a function that allows Clinic to get the issue category Add a function that allows Clinic to get the issue category from Doctor Apr 21, 2020
Copy link
Contributor

@jasnell jasnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We ought to be able to improve this API overall in a future iteration but this should work for now

index.js Outdated
@@ -174,6 +188,18 @@ class ClinicDoctor extends events.EventEmitter {
})
)

readStream(analysisStringified)
.then((result) => {
const issue = JSON.parse(result).issueCategory
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda taking the scenic route :)

The result value was just JSON.stringify-d when the analysisStringified stream was created a few lines up, so collecting that into a string and then JSON.parsing it again is actually not necessary. We could assign this.issue in the transform() callback (now on line 186). Or, maybe a bit cleaner, we could pull the new Analysis() call into its own variable and attach an on('data') handler to it to assign the this.issue value there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks, I didn't see that. That makes it much nicer

index.js Outdated
}

getIssue () {
return this.issue
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this separate function is useful given that it just returns a public property. Someone could just grab this.issue directly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah good shout, I didn't see that. Should issue be private or do you reckon it's alright to have it as a public member?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah good shout, I didn't see that. Should issue be private or do you reckon it's alright to have it as a public member?

I'm running into the unexpected '#' problem, I'm going to go with leaving it as a public member

@ConorDavenport ConorDavenport changed the title Add a function that allows Clinic to get the issue category from Doctor Add functionality that allows Clinic to get the issue category from Doctor Apr 30, 2020
@jasnell jasnell changed the base branch from master to main August 21, 2020 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants