gtg092x / gulp-sftp

Gulp SFTP Deploy
140 stars 61 forks source link

Callback #29

Open ghost opened 9 years ago

ghost commented 9 years ago

I might be missing something, but is there a way of creating a callback function that fires once the transfer is complete?

My usecase is that I was hoping to build SASS, minify, upload via FTP and reload BrowserSync (proxied to remote location). But depending on the speed of the upload, sometimes the BrowserSync refresh happens before the file has arrived!

I might be doing something wrong but it seems like it would be good to have a "callback" which accepts a function that fires oncomplete of the upload. Not sure how hard that would be to implement though?

gtg092x commented 9 years ago

@VoodooPrawn - I can explore this as a feature. Though I'll be honest, there should be some solution already available via some gulp control flow modules and those will probably be more sound.

ghost commented 9 years ago

@gtg092x - Ah right, I'm fairly new to Gulp so it's possible I'm coming at this from the wrong direction. Thanks for getting back to me though.

SavePointSam commented 9 years ago

I would love to have this as a feature so that I can trigger gulp-notify to let me know when the process is complete. Would be even better if I could send specific logs into it. (ex. 1 file uploaded successfully gets sent and I see a success message in OSX notifications.)

jmarquis commented 9 years ago

@SavePointSam +1

mwisconsin commented 9 years ago

I too would appreciate this feature.

sftp() sitting inside a gulp.src pipe() doesn't appear to trigger .on('end'), as far as I can tell.

@VoodooPrawn , @SavePointSam , did you manage to find a workaround?

ghost commented 9 years ago

@mwisconsin unfortunately not. Because we've started developing more stuff locally we've stopped using as much gulp-sftp anyways. However we still use it for some stuff so if anyone does come up with a solution or adds this functionality, it would still be appreciated.

jmarquis commented 9 years ago

I ended up throwing something together that works for me, but it doesn't use Gulp, so it might not be what you're looking for. Basically it's a command-line utility that reads a JSON config file, uses gaze to watch the current directory & subdirectories, pushes changes via ssh2 and then notifies via node-notifier when a transfer is complete. Works for me because I don't need to do any local compiling for the project I'm using it with.

I don't have much time to work on it but it does work (though it does have some weird disconnection errors sometimes). Maybe someone can fork it and make something better.

mwisconsin commented 9 years ago

For me, I need some way of indicating that the transfer is complete so that I can transfer the next file. The FTP server with which I'm communicating has some pretty severe bandwidth and connection limits, so I can't just transfer the files I want all at once. Add in that they're all going to different directories, and I can't just throw them as an array at gulp.src.

I tried using async, just as gulp-sftp does, but since gulp-sftp never brings back an indication that it's done, I can't call the next element in the array.

mwisconsin commented 9 years ago

Sheesh, I finish writing that, and then I had an idea, implemented it, and it worked.

Added this on line 164 of index.js:

if(options.callback) options.callback();

Now I can declare a Callback in the options of sftp(), and it works!

SavePointSam commented 9 years ago

@VooDooPrawn I haven't done anything. I just leave the console viewable while working. I may try to build the feature myself sometime down the road, I just don't have time right now.

ghost commented 9 years ago

@SavePointSam yea I basically do the same when we do use sftp. If you do manage to build anything, do let me know as I'd be interested in helping (when not too busy too hah)