Node's del command - callback not firing

后端 未结 3 932
栀梦
栀梦 2021-01-01 16:18

I\'m working through a pluralsight course on gulp. John Papa is demonstrating how to inject a function that deletes existing css files, into the routine that compiles the n

3条回答
  •  时光取名叫无心
    2021-01-01 17:08

    del isn't a Node's command, it's probably this npm package. If that's the case it doesn't receive a callback as second parameter, instead it returns a promise and you should call .then(done) to get it called after the del finishes.

    Update

    A better solution is to embrace the Gulp's promise nature:

    Change your clean function to:

    function clean(path) {
      return del(path); // returns a promise
    }
    

    And your clean-styles task to:

    gulp.task('clean-styles', function(){
      var files = config.temp + '/**/*.css';
      return clean(files);
    });
    

提交回复
热议问题