我正在创建一个插口文件,我想知道您是否可以将gulp-notify (或其他解决方案)与监视任务结合起来,以便在监视任务开始运行时弹出一条消息。从我的搜索中,我找不到任何关于我将如何做这件事的东西。这有可能吗?
这是我的监视任务:
// Watch our files for changes
gulp.task('watch', function() {
// -- I wanna run a notify message here saying 'Watching for changes...' -- //
gulp.watch('assets/styles/**/*.scss', ['styles']);
gulp.watch('assets/scripts/**/*.js', ['scripts']);
gulp.watch('assets/images/**/*', ['images']);
});发布于 2016-04-15 19:11:38
这应该可以做到:
gulp.task('watch', function() {
notify("Watching for changes...").write('');
gulp.watch('assets/styles/**/*.scss', ['styles']);
gulp.watch('assets/scripts/**/*.js', ['scripts']);
gulp.watch('assets/images/**/*', ['images']);
});此外,如果您打算在每次文件更改时都收到通知,则可以执行以下操作:
gulp.task('watch', function () {
//...
gulp.watch([
'./src/**/*.html',
'./src/**/*.php',
]).on('change', function () {
browserSync.reload();
notify("File changed: browser synced").write('');
});
});发布于 2015-06-05 21:42:34
我设法用gulp-notify和node-notifier完成了这项工作。在您吞噬任务之后,通过管道传递通知程序,并在回调中使用node通知程序来显示弹出窗口。
var notify = require('gulp-notify');
var nodeNotifier = require('node-notifier');
gulp().src(options.src)
.pipe(gulp.dest(options.dest))
.pipe(notify(function () {
nodeNotifier.notify({
'title': 'App',
'message': 'Build'
});
}));发布于 2015-06-04 21:02:49
你就不能直接用
gulp.task('watch', function() {
console.log('Watching for changes...');
gulp.watch('assets/styles/**/*.scss', ['styles']);
gulp.watch('assets/scripts/**/*.js', ['scripts']);
gulp.watch('assets/images/**/*', ['images']);
});https://stackoverflow.com/questions/30644518
复制相似问题