javascript - Gulp + Sass + Del - Random behaviour -


i don't understand why simple script behaves differently depending on del plugin setup.

when launch gulp sass want clean public/css dir , "compile" css sass. far good:

gulp.task('clean-css', del.bind(null,['./public/css']));  gulp.task('sass', ['clean-css'], function () {   return gulp.src('./resources/sass/**/*.scss')     .pipe(plugins.sass({outputstyle: 'compressed'}))      .pipe(gulp.dest('./public/css')); }); 

however if if change clean-css task to:

gulp.task('clean-css', del(['./public/css'])); 

then works every other time. first cleans , generates css, next 1 removes directory doesn't generate anything.

so, what's difference between del(['./public/css']) , del.bind(null,['./public/css'])? why affect script in way?

update: times when doesn't generate seeing error:

events.js:141       throw er; // unhandled 'error' event             ^ error: enoent: no such file or directory, open 'c:\users\xxxx\gulp-project\public\css\style.css'     @ error (native) 

tl;dr

gulp doesn't know when del finished if no callback provided. or without bind, del works every other time if sass task run before del , files deleted exist.


according gulp documentation should provide callback method del. how gulp knows when task finished:

var gulp = require('gulp'); var del = require('del');  gulp.task('clean:mobile', function (cb) {   del([     'dist/report.csv',     // here use globbing pattern match inside `mobile` folder     'dist/mobile/**/*',     // don't want clean file though negate pattern     '!dist/mobile/deploy.json'   ], cb); });  gulp.task('default', ['clean:mobile']); 

i suppose order in tasks run different each time, since gulp doesn't know when del finished when no callback provided. according documentation:

if want create series tasks run in particular order, need 2 things:

  1. give hint tell when task done,
  2. and give hint task depends on completion of another.

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -