I have a copy
task in my gulpfile.js
, and I want notify ( gulp-notify
) after copy is complete, now, when I execute copy
task, notify
function is called many times.
const notify = require('gulp-notify')
, gulp = require('gulp')
;
gulp.task('copy', copyTask);
function copyTask() {
return gulp.src('src/**/*')
.pipe(gulp.dest('dest'))
.pipe(notify('Copy task is completed!'));
}
In my terminal:
[13:23:40] Starting 'copy'...
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
[13:23:40] gulp-notify: [Gulp notification] Copy task is completed.
How to can I fix this, to execute only time, after gulp.dest
is completed?
You can use the onLast
option :
function copyTask() {
return gulp.src('src/**/*')
.pipe(gulp.dest('dest'))
.pipe(notify({
message: 'Copy task is completed!',
onLast: true
}));
}
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.