[英]How to execute notify after Gulp copy task is completed?
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. 我的
gulpfile.js
有一个copy
任务,我想在复制完成后通知( gulpfile.js
gulp-notify
),现在,当我执行copy
任务时, notify
函数被调用了很多次。
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? gulp.dest
完成后,如何解决此问题,仅执行时间?
You can use the onLast
option : 您可以使用
onLast
选项 :
function copyTask() {
return gulp.src('src/**/*')
.pipe(gulp.dest('dest'))
.pipe(notify({
message: 'Copy task is completed!',
onLast: true
}));
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.