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

feat: add reporter layer to support JSON output #97

Merged
merged 2 commits into from Apr 27, 2019

Conversation

@vostrik
Copy link
Contributor

@vostrik vostrik commented Apr 27, 2019

Added JSON output with --json argument.

Also added reporter layer to extend in future base reporters. It can be useful in integrations to such tools like Teamcity, etc.

#94

@ai
Copy link
Owner

@ai ai commented Apr 27, 2019

I like your architecture. But let’s reduce the number of classes. JsonReporter and HumanReporter will be enough.

runner.js Outdated
}

process.stdout.write('\n' + output + '\n')
reporter.logResults({ results, hint })
Copy link
Owner

@ai ai Apr 27, 2019

You do not need objects here. Just use arguments reporter.logResults(results, hint)

Copy link
Contributor Author

@vostrik vostrik Apr 27, 2019

Done in all methods

runner.js Outdated
@@ -486,6 +494,8 @@ main().catch(e => {
msg = e.stack
}

process.stderr.write(`${ chalk.bgRed(' ERROR ') } ${ chalk.red(msg) }\n`)
reporter.error({
message: `${ chalk.bgRed(' ERROR ') } ${ chalk.red(msg) }\n`
Copy link
Owner

@ai ai Apr 27, 2019

Should we move ERROR to a reporter?

Copy link
Contributor Author

@vostrik vostrik Apr 27, 2019

Yeah, I think so. Also in warn method?

Copy link
Owner

@ai ai Apr 27, 2019

Yeap

Copy link
Contributor Author

@vostrik vostrik Apr 27, 2019

Done for warn() and error() in HumanReporter

}
}

module.exports = {
Copy link
Owner

@ai ai Apr 27, 2019

We can directly export class here

Copy link
Contributor Author

@vostrik vostrik Apr 27, 2019

Ok.
Do you think that named export to save naming consistence in this case is bad practice?

Copy link
Owner

@ai ai Apr 27, 2019

I am exporting function directly without object wrap https://github.com/ai/size-limit/blob/master/index.js#L255

So for consistency, we should do the same with new files.

Copy link
Contributor Author

@vostrik vostrik Apr 27, 2019

Done for all new modules

@ai ai merged commit 44969eb into ai:master Apr 27, 2019
1 check passed
@ai ai mentioned this pull request Apr 27, 2019
@ai
Copy link
Owner

@ai ai commented Apr 27, 2019

I simplified code even more 27891e6

@ai ai mentioned this pull request Apr 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants