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 not found handler to prevent gulp interrupt when partial not found #5

Closed
wants to merge 1 commit into from

Conversation

elct9620
Copy link
Contributor

I add include support yesterday, but when I type "wrong partial filename" and ejs will throw a error.
Now, gulp-ejs will catch this error and return PluginError and gulp interrupt.

But I think work flow interrupt by this is very not comfortable, and I didn't want to restart gulp every time.
So I add notFoundHandler to handle ENOENT error and log it to prevent gulp interrupt.
(But I am not sure this is fit gulp suggest, I just think this may improve gulp-ejs experience.)

2014-02-22 11 21 15

@rogeriopvl
Copy link
Owner

I think that exiting gulp on ENOENT is more desirable.

Imagine that there are other tasks to run before and after gulp-ejs, that take some time to run. If a missing partial was found... I would have to wait for the entire build to finish to fix the partial path. And this assuming I was paying attention to gulp's output. So exiting on first error would force the user to immediately fix the problem to proceed.

Let me know what you think.

@elct9620
Copy link
Contributor Author

I am using https://github.com/KKBOX/FireApp before, and I want to focus on my webpage (with livereload)
So, I prefer to didn't direct exit gulp and warn the user on console ( or with gutil.beep )

But I search some information about "gulp handle error" and now I think keep throw ENOENT is good.
Gulp provide on method and error event, and I can customize the error handle method to keep gulp run or not.

Like this:

gulp.src("app/**/*.ejs")
       .pipe(ejs())
       .on("error", function(err) {
                             gutil.log(err);
                             this.emit("end"); // if not emit end, gulp will keep wait...
                         }
       )
       .pipe(gulp.dest("public/"));

So, I think this method is good than handle error in plugin.

@rogeriopvl
Copy link
Owner

Yes, gulp should not exit when using livereload (I was missing that). So I researched a little and found that the plugin is in need of a little update to improve the error reporting. I will update the code today.

And according to other plugins, that behaviour (to stop gulp or not) should be handled in the Gulpfile, just like you posted in your comment.

@rogeriopvl
Copy link
Owner

I've released v0.2.0. I also added an example on README.md file explaining how to deal with gulp-ejs errors and keep gulp running.

I'm going to close this for now.

@rogeriopvl rogeriopvl closed this Feb 27, 2014
@elct9620 elct9620 deleted the feature/include_support branch February 28, 2014 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants