[英]Gulp – notify after uploading a file via 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()
的回調中)。 “test”打印在控制台上,但通知是靜默的。
這似乎是一項簡單的任務,但對Node不熟悉會讓Gulp變得困難。
謝謝你的建議。
我想您可能希望直接使用node-notifier ,因為您需要通知除流的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'});
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.