teambition / gulp-ssh

SSH and SFTP tasks for gulp
184 stars 38 forks source link

Remote files are written with absolute local path #56

Closed t3rminus closed 6 years ago

t3rminus commented 8 years ago

When uploading using gulpSSH.dest, the remote path includes the entire local path.

So a project stored at /home/user/projects/api/index.js /home/user/projects/api/lib/util.js

gets deployed to the remote dest('/home/user/api') as /home/user/api/home/user/projects/api/index.js /home/user/api/home/user/projects/api/lib/util.js

instead of just /home/user/api/index.js /home/user/api/lib/util.js

Example:

gulp.task('deploy:staging:copy', function(){
    return gulp
        .src(['**/*'], { base: './' })
        .pipe(gulpSSH.dest('/home/user/api'));
});

I made a temporary work-around by adding a stream filter, as mentioned in #44 , which switches the file path for the relative file path:

gulp.task('deploy:staging:copy', function(){
    return gulp
        .src(['**/*'], { base: './' })
        .pipe(require('stream-filter').obj(function(file) {
            file.path = file.relative;
            return file;
        }))
        .pipe(gulpSSH.dest('/home/user/api'));
});

But this seems inefficient and contrary to what is expected.

mojavelinux commented 6 years ago

I agree that gulp-ssh should be using file.relative like vinyl-fs instead trying to manually relativize the file.

I'll propose a change.