gulp rsync忽略符号链接
我想同步一个包含符号链接的目录。此链接应作为符号链接传输 的文档说明了选项gulp rsync忽略符号链接,gulp,Gulp,我想同步一个包含符号链接的目录。此链接应作为符号链接传输 的文档说明了选项链接,似乎涵盖了这一点 使用可以解决gulp.src(不支持符号链接)的第一个问题。工作正常,符号链接除外,该链接被忽略,尽管由gulpDebug()列出 使用的gulpfile.js任务如下所示: const gulp = require('gulp'), gulpDebug = require('gulp-debug'), merge = require('merge-stream'),
链接
,似乎涵盖了这一点
使用可以解决gulp.src
(不支持符号链接)的第一个问题。工作正常,符号链接除外,该链接被忽略,尽管由gulpDebug()
列出
使用的gulpfile.js
任务如下所示:
const gulp = require('gulp'),
gulpDebug = require('gulp-debug'),
merge = require('merge-stream'),
rsync = require('gulp-rsync'),
vfs = require('vinyl-fs');
gulp.task('rsyncFiles', function (done) {
const rsyncSrcClient =
vfs.src('src/**')
.pipe(gulpDebug())
.pipe(rsync({
root: 'src/',
hostname: remoteHostname,
destination: remoteTargetDir + '/src/',
links: true
}));
return merge(rsyncSrcClient);
});
使用shell中的
rsync--link…
手动按需工作,符号链接将作为符号链接传输。添加选项emptyDirectories:true
解决了此问题
gulpfile.js
现在是:
gulp.task('rsyncFiles', function (done) {
const rsyncSrcClient =
vfs.src('src/**')
.pipe(gulpDebug())
.pipe(rsync({
root: 'src/',
hostname: remoteHostname,
destination: remoteTargetDir + '/src/',
links: true,
emptyDirectories: true
}));
return merge(rsyncSrcClient);
});
原因是文件内部的过滤机制
在上,对于符号链接,以下源代码片段始终为false
:
sources = sources.filter(function(source) {
return !source.isNull() ||
options.emptyDirectories ||
(source.path === cwd && options.recursive);
});
添加选项emptyDirectories:true
会将此行为更改为符号链接的结果true
。符号链接不再被过滤掉,rsync将根据需要传输链接