Gulp – 通过ftp上传文件后通知

我使用Gulp来观看文件,通过ftp进行更改,并在上传完成时发送通知。 我不知道如何连接这些插件,使其工作。 现在我有:

var gulp = require('gulp'), ftp = require('gulp-ftp'), watch = require('gulp-watch'), notify = require('gulp-notify'); var markupWatcher = watch({ glob: 'src/*.php', name: 'markup' }); markupWatcher.gaze.on('all', function(event, path) { options.remotePath = ftpData.remotePath; gulp.src(path) .pipe(ftp(options)) .on('finish', function() { console.log('test'); notify({title: 'File Uploaded', message: 'test'}); }); 

我认为通知需要传递给.pipe() ,但我不知道如何在这种情况下(在.on()callback中)。 控制台上打印“testing”,但通知是沉默的。

这似乎是一个简单的任务,但不熟悉Node使Gulp困难。

感谢您的任何build议。

我想你可能想直接使用node-notifier ,因为你需要通知一个事件而不是stream的data事件:

 var gulp = require('gulp'), ftp = require('gulp-ftp'), watch = require('gulp-watch'), Notification = require('node-notifier'); var notifier = new Notification(); var markupWatcher = watch({ glob: 'src/*.php', name: 'markup' }); markupWatcher.gaze.on('all', function(event, path) { options.remotePath = ftpData.remotePath; gulp.src(path) .pipe(ftp(options)) .on('finish', function() { console.log('test'); notifier.notify({title: 'File Uploaded', message: 'test'}); });