Skip to content

Instantly share code, notes, and snippets.

@sinpaout
Last active March 25, 2019 15:37
Show Gist options
  • Save sinpaout/04fecac681870720574e93bb6b3c381a to your computer and use it in GitHub Desktop.
Save sinpaout/04fecac681870720574e93bb6b3c381a to your computer and use it in GitHub Desktop.
auto rsync with gulp task over ssh
// gulpfile.js
var gulp = require( 'gulp' );
var rsync = require( 'gulp-rsync' );
var rsyncHost = process.env.RSYNC_HOST || '0.0.0.0';
var rsyncPort = process.env.RSYNC_PORT || 22;
gulp.task( 'watch', function() {
var targets = [
'./js/**'
];
var watcher = gulp.watch( targets, ['sync']);
watcher.on( 'change', function( evt ) {
// debug
console.log( 'file: ' + evt.path + ', ' + 'type: ' + evt.type );
});
});
// test_sshd is setup in ~/.ssh/config
gulp.task( 'sync', function() {
return gulp.src( 'js/**' )
.pipe( rsync({
hostname: 'test_sshd',
destination: '~/app/'
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment