使用gulp-sftp仅上载更改的文件

我有以下任务gulp:

gulp.task('sync-frontend', /*['build-frontend'],*/ function() { if(config.layout.frontend.syncOnBuild) return gulp .src(config.layout.frontend.distDir + '/**') .pipe(changed(config.layout.frontend.distDir, {hasChanged: changed.compareSha1Digest})) //.pipe(debug()) .pipe(gulp.dest(config.layout.frontend.distDir)) .pipe(sftp ({ host: config.sftp.host, port: config.sftp.port, user: config.sftp.user, pass: config.sftp.pass, remotePath: (config.layout.frontend.remotePath ? config.layout.frontend.remotePath : config.sftp.remotePath ) })); }); 

config.layout.frontend.distDir值是'httpdocs'。

问题是,没有文件正在上传,无论是否被改变(我已经试图离开hasChange改变选项的默认情况下,我总是得到以下输出:

 [20:45:52] Using gulpfile /Storage/Portable/Sync/Projects/Prataria/web-prataria/gulpfile.js [20:45:52] Starting 'sync-frontend'... [20:45:52] gulp-sftp: No files uploaded [20:45:52] Finished 'sync-frontend' after 503 ms 

有任何想法吗?

我碰到这个,发现gulp.src上的格式需要以./为前缀来find正确的文件夹。 所以试试./httpdocs作为config.layout.frontend.distDir的值。

你可以和另外一个库一起吞下去,比如“吞食”或者“吞食”。