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

Separate out into alex() and alex.reporter() #4

Closed
agnoster opened this issue Oct 9, 2015 · 6 comments
Closed

Separate out into alex() and alex.reporter() #4

agnoster opened this issue Oct 9, 2015 · 6 comments

Comments

@agnoster
Copy link

agnoster commented Oct 9, 2015

Most linters do something like this, and it may help overcome some issues with streams. If you have a large set of files, gulp-alex will only receive the first 16 because there's nothing "downstream" pulling in more.

Also, this would enable configuring the reporter separately to e.g. only output files that have warnings and so forth.

@dustinspecker
Copy link
Owner

That's a good idea to split the reporter out. I'll look into that soon.

Can you show how you're using gulp-alex in a Gulp task? Typically, when an issue similar to only the first 16 files being examined is due to not configuring the Gulp task quite right, in my experience at least. Make sure there's a return statement within the task. If there is, there might be a bug in gulp-alex that we'll need to look into.

@agnoster
Copy link
Author

It's about as minimal as can be:

gulp.task("alex", function() {
  gulp.src(content + "**/*.md")
    .pipe(alex())
});

This version quits after processing 16 files. If I put another task "downstream" it correctly pulls through the files (I've been lead to believe that this is because node streams don't keep pushing data unless something is "pulling" on the other end, but my understanding here is vague at best). So I tried adding something else downstream and, voila, this actually processes all the files (but then dumps the data into /tmp of course):

gulp.task("alex", function() {
  gulp.src(content + "**/*.md")
    .pipe(alex())
    .pipe(gulp.dest('/tmp'))
});

So ideally I'd like to not have to tack on something artificial to keep the stream fed, and looking at jshint it seems to split out the reporter as a separate task - which I like, but may actually be totally orthogonal to the issue I'm having.

See gulpjs/gulp#716, which seems to indicate it's a limitation of the through2 module, which gulp-alex also uses.

@dustinspecker
Copy link
Owner

Can you please try

gulp.task("alex", function() {
  return gulp.src(content + "**/*.md")
    .pipe(alex())
});

I believe adding the return statement should do the trick. If not, this is definitely a bug and I'll took a look into it.

@agnoster
Copy link
Author

That fixes my issue! Awesome!

It would still be nice to be able to configure it so it only outputs errors/warning and not all the files with "no issues found" - I have a lot of markdown files and only a few have issues. Also being able to emit the context would be cool but now I'm just getting greedy :-)

@agnoster
Copy link
Author

Just discovered { quiet: true }, but it still prints a ton of newlines which makes the output very weird when the warnings are relatively sparsely distributed.

@agnoster
Copy link
Author

I think I have a fix for that in #5 if that's desired behavior (I think it should be?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants