Skip to content

Instantly share code, notes, and snippets.

@kareemkibue
Last active December 30, 2021 23:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kareemkibue/03d6c66d662930822f1f7dd1de25ef86 to your computer and use it in GitHub Desktop.
Save kareemkibue/03d6c66d662930822f1f7dd1de25ef86 to your computer and use it in GitHub Desktop.
Gulp FTP Task with credentials include (vinyl-ftp)
{
"host": "HOSTNAME",
"user": "FTP_USERNAME",
"password": "FTP_PASSWORD",
"parallel": 10
}
/*Reference - https://www.npmjs.com/package/vinyl-ftp
install via npm - npm i --save-dev vinyl-ftp
*/
let ftp = require( 'vinyl-ftp' );
let debug = require( 'gulp-debug' );
let fs = require( 'fs' );
gulp.task( 'ftp', function() {
var ftpConfig = JSON.parse( fs.readFileSync( './ftp.json' ) );
var conn = ftp.create( ftpConfig );
var globs = [
/* folders, files come here */
// 'index.html',
// 'images/**'
// etc
];
return gulp.src( globs, {
base: '.',
buffer: false
} )
.pipe( debug() )
.pipe( conn.newer( '/public_html/' ) )
.pipe( conn.dest( '/public_html/' ) );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment