【问题标题】:vinyl-ftp does no upload乙烯基 ftp 不上传
【发布时间】:2015-03-30 17:52:32
【问题描述】:

我正在尝试使用 gulp 和vinyl-ftp (https://www.npmjs.com/package/vinyl-ftp) 通过 ftp 上传文件夹。 但是,使用示例配置,任务会运行,但它什么也不做。

似乎有一个日志功能,但我不知道我是否有任何日志。我只从 gulp 获得标准输出:

[08:54:22] Using gulpfile gulpfile.js
[08:54:22] Starting 'deploy'...
[08:54:22] Finished 'deploy' after 13 ms

我只是稍微修改了示例配置以满足我的需要:

var gulp = require( 'gulp' );
var gutil = require( 'gulp-util' );
var ftp = require( 'vinyl-ftp' );

gulp.task( 'deploy', function() {

var conn = ftp.create( {
    host:     'mywebsite.tld',
    user:     'me',
    password: 'mypass',
    parallel: 10,
    log: gutil.log
} );

var globs = [
    'src/**',
    'css/**',
    'js/**',
    'fonts/**',
    'index.html'
];


return gulp.src( globs, { base: 'path_to_my_folder', buffer: false } )
    .pipe( conn.newer( '/path_to_remote_folder' ) ) 
    .pipe( conn.dest( '/path_to_remote_folder' ) );

} );

我可以错过任何依赖吗?我正在运行优胜美地。

【问题讨论】:

  • 当vinyl-ftp 在节点8 上运行时,它会停止计算服务器时间偏移属性并需要手动timeOffset。

标签: ftp npm gulp


【解决方案1】:

快速拍摄:我认为base 属性在这里被滥用了。 base 参与您的 glob 并忽略其他文件名。你需要的是cwd:

return gulp.src( globs, { cwd: 'path_to_my_folder', buffer: false } )
    .pipe( conn.newer( '/path_to_remote_folder' ) ) 
    .pipe( conn.dest( '/path_to_remote_folder' ) );
});

【讨论】:

  • 上传新文件前如何清空远程文件夹?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-26
  • 1970-01-01
相关资源
最近更新 更多