gulp-rsync在Windows上,而不是在远程Linux服务器上制作目录

gulp-rsync on Windows not Making Directory on Remote Linux Server

本文关键字:服务器 Linux Windows gulp-rsync      更新时间:2023-09-26

我得到了以下gump任务,将文件从Windows 10机器传输到远程Linux服务器。但是,复制文件时使用反斜杠"''"vice forward slash"/",导致文件名像"js''myjs.js"一样长,而不是创建一个名为"js"的文件夹,其中包含"myjs.js"。我还没有找到解决此问题的选项或开关。你知道我做错了什么吗?

gulp.task('deploy', function() {
  return gulp.src('dist/*/')
   .pipe(rsync({
     options: {
      chmod: 'ugo=rwX',
      'r': true,
      'v': true,
      'delete': true,
      'verbose': true,
      'progress': true
   },
   username: "user",
   password: "pass",
   hostname: 'host.com',
   destination: '~/test/',
   recursive: true,
   clean: true,
   root: "dist/"
  }));
});

这个问题和解决方案在这里描述如下:

一饮而尽rsync index.js更改:

  source: sources.map(function(source) {
    return path.relative(cwd, source.path) || '.';
  }),

至:

  source: sources.map(function(source) {
    var file_path = (path.relative(cwd, source.path) || '.').replace( /''/g, '/')
    // console.log( 'gulp-rsync source:', source.path, ', ret: ', file_path );
    return file_path
  }),

relative()是罪魁祸首。

更好的解决方案

已经有一个stcruy's fork的gullow-rsync解决了这个问题。要部署它,请执行以下操作:

npm remove -D gulp-rsync
npm install -D https://github.com/stcruy/gulp-rsync.git