0

In my project i need gulp to watch files for changes in my /src/ folder and upload them to /public/ ftp folder.

The problem is - it takes too long because vinyl-ftp first gets listing of all folders in project by alphabet and uploads new files only then it reach the folder that contains changed file.

Here is my deploy task:

gulp.task('deploy', function () {

var conn = ftp.create({
    host: '123',
    user: '123',
    password: '123',
    parallel: 1,
    log: gutil.log
});

var globs = [
    'src/**',
    '!' + baseskindir + '_fonts/**',
    '!' + baseskindir + '_img/**',
    '!' + baseskindir + '_js/**',
    '!' + baseskindir + '_scss/**',
    '!' + baseskindir + 'css/maps/**',
    '!' + baseskindir + '_sprite/**'
];

// using base = '.' will transfer everything to /public_html correctly
// turn off buffering in gulp.src for best performance

return gulp.src(globs, {base: './src', buffer: false})
        .pipe(conn.newerOrDifferentSize('/123/public')) // only upload newer files
        .pipe(conn.dest('/123/public'));

});

Result of this task:

     Starting 'deploy'...
[17:14:02] CONN 
[17:14:03] READY
[17:14:03] MLSD  /stage.123.com/
[17:14:03] LIST  /stage.123.com/
[17:14:03] MLSD  /stage.123.com/public
[17:14:03] LIST  /stage.123.com/public
[17:14:03] MLSD  /stage.123.com/public/GeoIp
[17:14:03] LIST  /stage.123.com/public/GeoIp
[17:14:04] MLSD  /stage.123.com/public/skin
[17:14:04] LIST  /stage.123.com/public/skin
[17:14:04] MLSD  /stage.123.com/public/app
[17:14:04] LIST  /stage.123.com/public/app
[17:14:04] MLSD  /stage.123.com/public/js
[17:14:04] LIST  /stage.123.com/public/js
[17:14:04] MLSD  /stage.123.com/public/skin/adminhtml
[17:14:04] LIST  /stage.123.com/public/skin/adminhtml
[17:14:04] MLSD  /stage.123.com/public/app/code
[17:14:04] LIST  /stage.123.com/public/app/code
[17:14:04] MLSD  /stage.123.com/public/app/design
[17:14:04] LIST  /stage.123.com/public/app/design
[17:14:04] MLSD  /stage.123.com/public/skin/frontend
[17:14:04] LIST  /stage.123.com/public/skin/frontend
[17:14:05] MLSD  /stage.123.com/public/app/etc
[17:14:05] LIST  /stage.123.com/public/app/etc
[17:14:05] MLSD  /stage.123.com/public/app/locale
[17:14:05] LIST  /stage.123.com/public/app/locale
[17:14:05] MLSD  /stage.123.com/public/js/onestepcheckout
[17:14:05] LIST  /stage.123.com/public/js/onestepcheckout

And it goes on and on until it reaches folder with changed file.

It will upload it sooner or later, but i just cant wait for it anymore.

DesuNyan
  • 5
  • 4
  • You haven't posted your watch code, so I can only guess that you're executing the entire `deploy` task on every change. In that case using [`gulp-watch`](https://www.npmjs.com/package/gulp-watch) in your stream would probably be the better approach. – Sven Schoenung Sep 12 '16 at 15:23
  • Here's my watch task i forgot to post: `gulp.task('watch', function () { gulp.watch(baseskindir + '_scss/**/*.scss', ['sass']); gulp.watch(baseskindir + '_js/**/*.js', ['js']); gulp.watch(baseskindir + '_sprite/*.png', ['sprite']); gulp.watch(baseskindir + '_img/**/*', ['images']); });` It actually watching for changes, problem is in deployer - it cant upload only changed files - it tries to upload everything. – DesuNyan Sep 13 '16 at 09:47

0 Answers0