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 new API method for failing build upon validation error #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Add new API method for failing build upon validation error #4

wants to merge 5 commits into from

Conversation

ssoloff
Copy link

@ssoloff ssoloff commented Dec 13, 2016

This is a minor usability improvement intended for scenarios where the user wishes to fail the build if a validation error occurs and there is no need to further process the stream after validation. I followed the example of numerous other Gulp plugins and simply added a new API method named failOnError() to which the stream can be piped if the user desires to fail the build upon validation error. Providing such an API allows the user to easily fail the build without having to add the boilerplate currently documented in readme.md. As the build failure trigger is not coupled to validate(), it does not prevent the user from continuing to process the stream if they choose.

Note that this PR also includes a few small refactorings. I introduced some duplication while adding this feature and didn't want to leave the code worse than I found it. Please advise if you think these refactorings (e8381d7 and b94a964/266a128) are out-of-scope for the PR and should be removed.

Any other suggestions you may have for improvement are welcome!

Piping the validation results to the stream returned from this method
will stop the task and report an error if the validation failed for any
reason.
var error = null;

function size(arr) {
Copy link
Author

Choose a reason for hiding this comment

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

I added this function to avoid adding a dependency on Underscore or Lodash.

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

Successfully merging this pull request may close these issues.

1 participant