我的copy
中有一个gulpfile.js
任务,我希望在复制完成后通知(gulp-notify
),现在,当我执行copy
任务时,{{ 1}}函数被多次调用。
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!'));
}
如何解决这个问题,在[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.
完成后只执行时间?
答案 0 :(得分:2)
您可以使用onLast
option:
function copyTask() {
return gulp.src('src/**/*')
.pipe(gulp.dest('dest'))
.pipe(notify({
message: 'Copy task is completed!',
onLast: true
}));
}