【问题标题】:Vinyl FTP upload specific directory黑胶FTP上传特定目录
【发布时间】:2018-01-17 18:30:06
【问题描述】:

我正在尝试让 Gulp Vinyl FTP 上传特定的 Wordpress 主题目录,这是部署命令。

gulp.task('deploy', function() {
    console.log('uploading to server');

    var conn = ftp.create({
        host: '',
        user: '',
        password: '',
        parallel: 3,
        log: gutil.log
    });

    var globs = [
    'wp-content/themes/theme2018/**/*',
    'wp-content/themes/theme2018/*',
        // '**/*',
        // '*',
        // '!node_modules/**',
        // '!node_modules/',
        // '!.env'
    ];

    return gulp.src( globs, { base: '.', buffer: false } )
            .pipe( conn.newer( '/public_html' ) ) // only upload newer files 
            .pipe( conn.dest( '/public_html' ) )
})

在我运行部署命令后,它显示如下:

[11:20:34] Using gulpfile D:\Cloud\Work\Website.com\gulpfile.js
[11:20:34] Starting 'deploy'...
uploading to server
[11:20:34] CONN
[11:20:35] READY
[11:20:35] MLSD  /public_html
[11:20:35] Finished 'deploy' after 786 ms

但是,主题目录中的文件都没有上传。

任何想法我做错了什么?

【问题讨论】:

    标签: gulp vinyl-ftp gulp-ftp


    【解决方案1】:

    base 选项添加到更新

    .pipe(conn.newer('/public_html'), { base: '.'})

    你可以在创建ftp时使用debug选项

    const gutil = require( 'gulp-util' );
    let conn = ftp.create({
        log:        gutil.log,
        debug:      gutil.log
    });
    

    最后,尝试 2 使用 dest insted newer

    【讨论】: