Last active
December 30, 2021 23:50
-
-
Save kareemkibue/03d6c66d662930822f1f7dd1de25ef86 to your computer and use it in GitHub Desktop.
Gulp FTP Task with credentials include (vinyl-ftp)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"host": "HOSTNAME", | |
"user": "FTP_USERNAME", | |
"password": "FTP_PASSWORD", | |
"parallel": 10 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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