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

Custom Reporters / Printers #19

Closed
shellscape opened this issue Jul 4, 2018 · 5 comments
Closed

Custom Reporters / Printers #19

shellscape opened this issue Jul 4, 2018 · 5 comments

Comments

@shellscape
Copy link

(You might have noticed that I'm enthusiastic about your project 😄)

While the default output is definitely colorful, distinct, and pleasant to look at, I'd like to request the ability to use a custom reporter / printer for controlling the styles applied to the output. I'd like to use this as a component in a project that follows the "stylish conventions" and a custom reporter would help me to keep the output for whybundled in line with that style.

@d4rkr00t
Copy link
Owner

d4rkr00t commented Jul 4, 2018

Yeah, it definitely makes sense, I'll have a look at adding custom print functions asap.

@d4rkr00t
Copy link
Owner

d4rkr00t commented Jul 4, 2018

I've been thinking about that, and even though it's not hard to add a custom print function, I want to better understand your use case.

I don't think it's a good idea to use commands/{default|by}.js as an Node API for whybundled, because these functions handle lots of cli specific things e.g. progress bar, reading files from fs, killing the process in case something goes wrong, etc... I can extract non-cli specific stuff from commands and provide them as an API, which seems totally reasonable.

But if you don't need the logic inside commands, if default behaviour is enough, you can use analyze and build your own print:

const { analyze } = require('whybundled');
const report = analyze(stats);
customPrint(report);

@shellscape
Copy link
Author

Oh we'd totally be using whybundled via the CLI, just through child_process/execa. A --reporter flag is what I was going after (sorry, should have been more specific about that in the original message). Mocha et. al. does pretty much the same. Since webpack-command handles using the webpack API to run builds, the idea that was simply to have the buildchild_process pipe to the whybundled process behind the scenes, removing an additional step for users. With a custom reporter we'd also add a byline so folks knew where the info was being generated from (this project).

Since this was conceived as a CLI, I didn't want to make a request that the API be opened up - I don't think that work is needed.

@d4rkr00t
Copy link
Owner

d4rkr00t commented Jul 4, 2018

Oh, ok :) Cool! It shouldn't be much work to add that. I'll try and put up a PR in couple of days.

d4rkr00t added a commit that referenced this issue Jul 26, 2018
@d4rkr00t
Copy link
Owner

Published as v1.4.0

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