Guest User

Untitled

a guest
Feb 19th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. const gutil = require('gulp-util');
  2. const ftp = require( 'vinyl-ftp' );
  3. const sftp = require('gulp-sftp');
  4.  
  5. // task for deploying files on the server
  6. gulp.task('deploy', function() {
  7. const config = require('./sftp-config.json');
  8.  
  9. const globs = [
  10. 'folder/file',
  11. 'folder/file',
  12. 'folder/file',
  13. ];
  14.  
  15. if (config.type == 'ftp') {
  16. // FTP version
  17. const conn = ftp.create( {
  18. host: config.host,
  19. user: config.user,
  20. password: config.password,
  21. port: config.port,
  22. parallel: 10,
  23. reload: true,
  24. debug: function(d){console.log(d);},
  25. log: gutil.log
  26. });
  27. return gulp.src( globs, { base: '.', buffer: false } )
  28. .pipe( conn.newer( '/dest_folder/' ) ) // only upload newer files
  29. .pipe( conn.dest( '/dest_folder/' ) );
  30. } else {
  31. // SFTP version
  32. const conn = sftp({
  33. host: config.host,
  34. user: config.user,
  35. pass: config.password,
  36. port: config.port,
  37. remotePath: config.remote_path,
  38. });
  39. return gulp.src(globs, { base: '.', buffer: false } )
  40. .pipe(conn);
  41. }
  42. });
Add Comment
Please, Sign In to add comment