morris / vinyl-ftp

Blazing fast vinyl adapter for FTP
Other
388 stars 31 forks source link

Error loading via src #109

Open lipatoff opened 6 years ago

lipatoff commented 6 years ago

My code:

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

gulp.task('load', function () {
    return conn.src('/mysite/project.zip')
    .pipe(gulp.dest('zip'));
});

But, after upgrading to version 6, I get:

CONN
READY
MLSD /mysite
LIST /mysite
GET \mysite\project.zip

when it should be: GET /mysite/project.zip

How to fix it?

c512970 commented 6 years ago

I ran into the same problem, tried to find the answer to this question in google, but found only this issue without an answer. Therefore I had to solve the problem myself :)

ATTENTION!!! I understand that this is a very bad decision, but I do not know how to do it right. In order for .src to start working, you need to 1) Open the file _nodemodules/vinyl-ftp/lib/src.js 2) Find in this file the line "function getContents (file, cb) {" 3) Insert after this line the following code:

let fixedFilePath = file.path;
fixedFilePath = fixedFilePath.replace (/\\/ g, "\/");

4) Replace the lines if (options.buffer) return self.downbuffer (file.path, onContents); and self.downstream (file.path, onContents); on if (options.buffer) return self.downbuffer (fixedFilePath, onContents); self.downstream (fixedFilePath, onContents); respectively

I noted the changes on this picture: https://i.imgur.com/tKpRa7g.png

ATTENTION!!! I remind you that this is a bad solution, because every time you reinstall vinyl-ftp, you will need to do it again. But, nevertheless, it works.

P.S. Sorry for my english.