gulp-sftp icon indicating copy to clipboard operation
gulp-sftp copied to clipboard

Callback

Open ghost opened this issue 9 years ago • 11 comments

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?

ghost avatar Mar 17 '15 11:03 ghost

@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.

gtg092x avatar Mar 19 '15 22:03 gtg092x

@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.

ghost avatar Mar 20 '15 08:03 ghost

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.)

SavePointSam avatar Apr 07 '15 21:04 SavePointSam

@SavePointSam +1

jmarquis avatar Apr 18 '15 21:04 jmarquis

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?

mwisconsin avatar Jun 24 '15 15:06 mwisconsin

@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.

ghost avatar Jun 24 '15 15:06 ghost

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.

jmarquis avatar Jun 24 '15 16:06 jmarquis

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 avatar Jun 24 '15 17:06 mwisconsin

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!

mwisconsin avatar Jun 24 '15 17:06 mwisconsin

@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.

SavePointSam avatar Jun 24 '15 19:06 SavePointSam

@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)

ghost avatar Jun 25 '15 07:06 ghost