Sublime Forum

Calling SFTP method from Build System

#1

Hi,

I’m new to SublimeText but am liking what I’ve seen so far (was a Coda user before). My build processes are not very time-consuming and therefore I’d like to use a workflow where by I update documentation, minify js/css, etc upon each save. I’m using the onSaveBuild package for this.

I know I can set the SFTP package up to upload the current file on Save. However, since I’m also updating/creating other files upon save (documentation, minified js files), it would be great if I could call “Sync Local -> Remote…” as the final step in my Build process.

Is that possible and if so, can somebody please explain how?

0 Likes

#2

If you look at the file Packages/SFTP/Side Bar.sublime-menu you will get info about the command names and how to pass paths to them. By default Sublime will fill in the paths parameter with an array of the selected paths.

We can then use this info combined with the API Reference to call any of the SFTP commands at any given time. Please note that the package uses sublime_plugin.WindowCommand as the base (as opposed to a TextCommand), so they need to be called from a window object and not a view object.

Here is some code that should do what you are looking for.

sublime.active_window().run_command('sftp_sync_up', {paths: '/path/to/your/folder']})
0 Likes

#3

Great! Thanks a lot. I’ll delve into this.

0 Likes