gtg092x / gulp-sftp

Gulp SFTP Deploy
140 stars 61 forks source link

Known file size is required #62

Open hgwood opened 8 years ago

hgwood commented 8 years ago

gulp-sftp requires the size of all uploaded files to be known, otherwise it crashes on this line: https://github.com/gtg092x/gulp-sftp/blob/master/index.js#L272. Since Gulp is supposed to be the streaming build system, and gulp-sftp is only using the size for logging (it seems), I would suggest removing the requirement. For example, gulp-sftp could only print the progress in percentage if the size is known.

My use case is zipping a folder and uploading it immediately without writing it to the local file system.

I'm willing to make a PR but I would first like a sign from @gtg092x.

jean343 commented 7 years ago

I agree, I have the opposite use case and I would like to unzip a local archive.tar.gz and ftp it.

  return gulp.src(path)
    .pipe(gunzip())
    .pipe(untar())
    .pipe(sftp({
      host: '***',
    }));

It fails like

var size = file.stat.size;
TypeError: Cannot read property 'size' of null
    at D:\Sites\admin_react\node_modules\gulp-sftp\index.js:272:37
hgwood commented 7 years ago

@jean343 The workaround I use currently is this:

const gulpSftp = require('gulp-sftp');
const vinylFs = require('vinyl-fs');
...
.pipe(...)
.pipe(vinylFs.dest(tmp)) // have to do this because gulpSftp needs file sizes
.pipe(gulpSftp({host, user, pass, remotePath}))

gulp.dest instead of vinylFs.dest should work as well.

daniellacosse commented 7 years ago

made a terrible fork that sort of fixes this https://github.com/daniellacosse/gulp-sftp