javascript - Gulp and FTP : How to transfer only the content of a folder? - Stack Overflow

Gulp with vinyl ftp : how to specify different directory name?I am using vinyl-ftp with gulp to push m

Gulp with vinyl ftp : how to specify different directory name? I am using vinyl-ftp with gulp to push my local dist/ directory to remote production server.

Thing is my local ready-to-production directory name is "dist", and I want all of its content to be pushed in a "www" directory on the server.

The code is :

gulp.task( 'deploy:prod', ['build:dist'], function() {

    var conn = ftp.create( {
        host:     'ftp.website',
        user:     'username',
        password: 'password'
    } );

    var globs = ['./dist/**'];

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

As you see, I'm trying to get only the content of dist/ by targeting './dist/**', but after transfer is done, the path I get is : /www/dist/.

One workaround would be to rename my "dist/" folder to "www/" and then set vinyl ftp's destination to server ROOT, but I'd prefer to keep concerns separated and keep the name "dist/" for my local build.

Do you have any ideas on how to have the content of my local dist/ folder transferred into the remote www/ folder ?

Gulp with vinyl ftp : how to specify different directory name? I am using vinyl-ftp with gulp to push my local dist/ directory to remote production server.

Thing is my local ready-to-production directory name is "dist", and I want all of its content to be pushed in a "www" directory on the server.

The code is :

gulp.task( 'deploy:prod', ['build:dist'], function() {

    var conn = ftp.create( {
        host:     'ftp.website.',
        user:     'username',
        password: 'password'
    } );

    var globs = ['./dist/**'];

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

As you see, I'm trying to get only the content of dist/ by targeting './dist/**', but after transfer is done, the path I get is : /www/dist/.

One workaround would be to rename my "dist/" folder to "www/" and then set vinyl ftp's destination to server ROOT, but I'd prefer to keep concerns separated and keep the name "dist/" for my local build.

Do you have any ideas on how to have the content of my local dist/ folder transferred into the remote www/ folder ?

Share Improve this question edited Mar 26, 2015 at 1:33 cimmanon 68.4k17 gold badges168 silver badges172 bronze badges asked Mar 26, 2015 at 1:16 lapinlapin 2,1483 gold badges22 silver badges32 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 9

Try to set your base to ./dist/:

return gulp.src( globs, {base: './dist/', buffer: false } )
    .pipe( conn.differentSize( 'www/' ) ) 
    .pipe( conn.dest( 'www/' ) );

According to the API documentation and some blurred memories this flag's for exactly that case.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744198050a4562748.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信