Skip to content

Instantly share code, notes, and snippets.

@nandunbandara
Created July 25, 2017 17:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nandunbandara/1fdf340ed98c6bc52c20baf910b936ef to your computer and use it in GitHub Desktop.
Save nandunbandara/1fdf340ed98c6bc52c20baf910b936ef to your computer and use it in GitHub Desktop.
FTP Upload to remote server
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var ftp = require('vinyl-ftp');
var user = process.env.FTP_USER;
var pwd = process.env.FTP_PWD;
var localFiles = [
'./assets/**/*',
'./*.ico',
'./*.js',
'./*.html'
];
var remoteLocation = 'public_html/v2/';
function getFtpConnection(){
return ftp.create({
host: enter_your_host_here,
port: 21,
user: user,
password: pwd,
parallel: 5,
log: gutil.log
})
}
//deploy to remote server
gulp.task('remote-deploy',function(){
var conn = getFtpConnection();
return gulp.src(localFiles, {base: '.', buffer: false})
.pipe(conn.newer(remoteLocation))
.pipe(conn.dest(remoteLocation))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment