gulp updates hook?
jdavidbakr opened this issue · 7 comments
Is there an easy way to update gulp so that it triggers something for this plugin to sync? Right now I have to wait for gulp to finish and then perform a manual sync which usually take a few seconds longer than the regular sync.
You want gulp to run, and then sync ?
I could add a local_pre_command
and a local_post_command
to run a command locally before and after a sync i performed, but triggering a gulp build on each save might be too much.
Not sure what you mean by regular sync vs. manual sync - each time you save a single file that file alone is synced to the remote. ⌘12 syncs syncs all changed files, and will be a bit slower as it has to look at all the files.
Since gulp is run from the command line, the plugin doesn't recognize that the file(s) have changed, so I have to run ⌘12 after running gulp. Normally my process looks like this:
- Gulp watch is running in the backgourd
- I change a file, say one of my '.less' files.
- I wait for gulp to notify me that it has completed
- I hit ⌘12 to sync the newly compiled file
- Now I can see the changes on the server
That would require something like Apple Script support in Sublime Text (which would be an awesome feature).
You could run the watch command on the remote end, then each file synced would trigger the rebuild.
If you use iTerm 2 you could set up a trigger to react to the output of gulp, and run a command that in turn would trigger a Keyboard Maestro macro that would switch to SublimeText and press ⌘12 for you.
Or you could just call Keyboard Maestro directly from gulp.
@davidolrik That's fantastic, I'll check that out.
I just learned about subl --command
which is totally awesome!
This lets you call commands from outside Sublime Text! - Put something like this in your gulp file.js
:
At the top require gulp-exec:
var exec = require('gulp-exec');
Put this in your watch task callback:
exec('subl --command "rsync_ssh_sync"', function (err, stdout, stderr) {});
@davidolrik - that's even better. I am using Laravel, your comment led me to an even easier solution:
var elixir = require('laravel-elixir');
var gulp = require('gulp');
var shell = require('gulp-shell');
elixir(function (mix) {
mix.less('app.less');
mix.scriptsIn('resources/assets/js', 'public/js');
mix.version([
'css/app.css',
'js/all.js'
]);
mix.task('sync');
});
gulp.task('sync', function() {
gulp.src('').pipe(shell('if [ -x /usr/local/bin/subl ]; then /usr/local/bin/subl --command "rsync_ssh_sync"; fi'));
});