I decided to use vinyl-ftp for my deployment process in gulp. One thing I would like to do is to have a separate file with my ftp credentials:
host
user
password
and put that file in my .gitignore. And then I want those credentials in that file be read by my connection variable in my gulp file. My deploy code is the following:
gulp.task( 'deploy', function () { var conn = ftp.create( { host: 'yourdomain.com', user: 'ftpusername', password: 'ftpuserpassword', parallel: 10, log: gutil.log } ); var globs = [ 'dist/**' ]; return gulp.src( globs, { base: './dist/', buffer: false } ) .pipe( conn.newer( 'yourdomain.com' ) ) .pipe( conn.dest( 'yourdomain.com' ) ); } );//end deploy
So I want the values of the variables yourdomain.com for the host, ftpusername for user and ftpuserpassword for password be read in from a separate file so my credentials show up when I do git push. How do I accomplish this?
Thanks
You can pass them as run args:
Then call it from command line or put the line in a batch file:
npm run gulp deploy -- --host=hostname --user=username --password=password --remotedir=/path/to/folder/on/server
. Usegulp
instead ofnpm run gulp
if gulp is installed global.This is a good practice to pass credentials trough args at a program start.