gulp 通知依赖于没有 .pipe 的任务完成

gulp notification dependent on task completion without .pipe

我知道我可以使用 node-notifier 但是是否有更好的方法来设置依赖于任务完成的通知(并且不使用 .pipe)

下面的方法可行,但有没有办法在一个任务中实现这个?

// Perform data task
gulp.task('imgData1', function() { 
  imageExport.record({
    path: path.images_src,
    output: path.images_data,
    template: 'custom.hbs',
    breakpointDelimiter: '--'
  })
});

// Perform notification task 
gulp.task('imgData2', ['imgData1'], function() {
  notifier.notify({
  'title': 'My notification',
  'message': 'Data task complete!'
});
});

// Perform data task then the notification task 
gulp.task('imgData', ['imgData2']);

image-size-export accepts a callbackimageExport.record() 完成时调用。在该回调中只需 运行 notifier.notify()

gulp.task('imgData', function() { 
  imageExport.record({
    path: path.images_src,
    output: path.images_data,
    template: 'custom.hbs',
    breakpointDelimiter: '--'
  }, function() {
     notifier.notify({
       'title': 'My notification',
       'message': 'Data task complete!'
     });
  });
});