Cannot sequentialize gulp-rsync
Opened this issue · 3 comments
I'm using the run-sequence
package in tandem with gulp-rsync
to sequentialize gulp tasks. I see this in the log:
[14:21:00] Finished 'rsync-assets' after 681 μs
Apparently, gulp-rsync
returns right away and the rsync process is executed in the background, I guess.
How can I sequentialize gulp-rsync
?
Hey @mondalaci did you find a solution to this? I need to be able to run another task once the rsync transaction actually completes.
Hey @imakewebsites,
I totally forgot the details because it's been awhile but according to my memory I managed to make it work. Please see the script below. It did work but I have no idea regarding the details.
var sshConfig = {...};
var gulp = require('gulp');
var browserify = require('gulp-browserify');
var concat = require('gulp-concat');
var fileInclude = require('gulp-file-include');
var less = require('gulp-less');
var run = require('gulp-run');
var runSequence = require('run-sequence');
var ssh = require('gulp-ssh')({ignoreErrors:false, sshConfig:sshConfig});
function dumpError (error) {
console.log(error.toString());
this.emit('end');
}
// Index page
gulp.task('index-css', function() {
return gulp.src(['assets/index/index.less'])
.pipe(less())
.on('error', dumpError)
.pipe(gulp.dest('build'));
});
gulp.task('index-js', function() {
return gulp.src('assets/index/index.js')
.pipe(browserify())
.on('error', dumpError)
.pipe(concat('index.js'))
.pipe(gulp.dest('build'))
});
gulp.task('index-html', function() {
return gulp.src('assets/index/index.html')
.pipe(fileInclude('@@'))
.on('error', dumpError)
.pipe(gulp.dest('build'));
});
// Shared assets
gulp.task('shared-css', function() {
return gulp.src(['assets/shared/shared.less'])
.pipe(less())
.on('error', dumpError)
.pipe(gulp.dest('build'));
});
gulp.task('shared-js', function() {
return gulp.src('assets/shared/shared.js')
.pipe(browserify())
.on('error', dumpError)
.pipe(concat('shared.js'))
.pipe(gulp.dest('build'))
});
gulp.task('shared-html', function() {
return run('rsync assets/shared/*.html build').exec();
});
gulp.task('rsync-assets', function() {
return run('rsync ...').exec();
});
gulp.task('update-index-dev', function() {
var wpCliCmd = 'wp-cli ... ';
return ssh.shell([wpCliCmd + 'post update 361 ...'])
.on('error', dumpError)
.on('data', function(file) {
console.log(file.contents.toString());
});
});
gulp.task('deploy', function() {
return ssh.shell(['cp ...',
'/root/wp-page-updater/wp-page-updater.js prod'])
.on('error', dumpError)
.on('data', function(file) { console.log(file.contents.toString()) });
});
// Sync scripts
gulp.task('deploy', function() {
return ssh.shell(['cp ...',
'/root/wp-page-updater/wp-page-updater.js prod'])
.on('error', dumpError)
.on('data', function(file) { console.log(file.contents.toString()) });
});
gulp.task('update-wp-page-updater', function() {
return run('rsync ...').exec();
});
// Watchers
gulp.task('watch', function() {
// Index page
gulp.watch('assets/index/*.less', ['index-css']);
gulp.watch('assets/index/*.js', ['index-js']);
gulp.watch(['assets/index/*.html', 'build/index.{css,js}'], function() {
runSequence('index-html', 'rsync-assets', 'update-index-dev');
});
// Shared assets
gulp.watch('assets/shared/*.less', function() { runSequence('shared-css', 'rsync-assets'); });
gulp.watch('assets/shared/*.js', function() { runSequence('shared-js', 'rsync-assets'); });
gulp.watch('assets/shared/*.html', function() { runSequence('shared-html', 'rsync-assets'); });
// Scripts
gulp.watch('wp-page-updater/wp-page-updater.js', ['update-wp-page-updater']);
});
gulp.task('update', ['index-css', 'index-js', 'index-html', 'shared-css', 'shared-js']);
gulp.task('default', ['watch']);
Thanks so much for the response. Seems you ditched the gulp-rsync plugin altogether and went with a gulp-run task firing off a rsync command in shell.