简体   繁体   中英

gulp notification dependent on task completion without .pipe

I know I can use node-notifier but is there a better way to set up a notification which is dependent on a task being complete (and which does not use .pipe)

The below works but is there a way to achieve this within a single task?

// 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 callback that is invoked when imageExport.record() has finished. Simply run notifier.notify() in that callback:

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!'
     });
  });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM