Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does gulp quit without finishing my task?

Tags:

gulp

pug

I have the following gulp task:

var jade = require('gulp-jade');
var data = require('gulp-data');

gulp.task('jade', function(done) {
  return gulp.src(paths.jade)
    .pipe(data(function(){}))
    .pipe(jade())
    .pipe(gulp.dest('./www/templated/'));
});

Which is trying to compile this jade file:

#{something.anything}

But when I try to run the task, the jade task quits without finishing:

$ gulp jade
[14:39:24] Using gulpfile ~/path/gulpfile.js
[14:39:24] Starting 'jade'...

$

And no output file is generated.

I'm clearly missing something obvious here, but I can't tell what. Searches for 'gulp task not finishing' and the like only yield a lot of results discussing tasks which never finish.

I am running the latest versions of gulp, gulp-jade and gulp-data (3.8.11, 1.0.0 and 1.2.0).

If I remove the pipe to data, everything works. I have tried modifying the call to data, even requiring a valid json file as in the gulp-data example, but it still will not work.

Why is gulp exiting without the task completing and without, seemingly, any error?

like image 730
Codebling Avatar asked Feb 24 '15 20:02

Codebling


People also ask

How do you define a task in Gulp?

To have your tasks execute in order, use the series() method. For tasks to run at maximum concurrency, combine them with the parallel() method. Tasks are composed immediately when either series() or parallel() is called. This allows variation in the composition instead of conditional behavior inside individual tasks.

What is Gulp watch command?

Advertisements. The Watch method is used to monitor your source files. When any changes to the source file is made, the watch will run an appropriate task. You can use the 'default' task to watch for changes to HTML, CSS, and JavaScript files.

How do I copy files using Gulp?

var copy = require('gulp-copy'); gulp. task('copy-resources', function() { return gulp. src('./src/img/*. png') .


1 Answers

The problem is, you have a bug in your .jade file which is causing gulp-jade to throw an error. Ideally, gulp-jade would throw a friendlier gulp error, giving you more info than just a blank screen but, since it's not, you need to handle this error yourself. You can either use gulp-plumber or handle errors coming directly out of that particular pipe manually like so:

var gutil = require('gulp-util');

gulp.task('jade', function() {
  return gulp.src(paths.jade)
    .pipe(jade())
    .on('error', gutil.log)
    .pipe(gulp.dest('./www/templated/'));
});

If you're interested, here are some more details on this error management problem in gulp.

like image 134
Chris Montgomery Avatar answered Sep 19 '22 06:09

Chris Montgomery