Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var gulp = require('gulp'),
- gutil = require('gulp-util'),
- vftp = require('vinyl-ftp');
- var fconfig {
- host: "127.0.0.1",
- port: "21",
- user: "root",
- password: "top-secret-tacos",
- simultaneous_connections: 5,
- local_path: ".",
- remote_path: "/my_path/as_seen/in_ftp/",
- globs: {
- "/assets/src/**/*.*css",
- "/assets/src/**/*.js",
- "/assets/dist/**/*"
- }
- };
- function getFtpConnection() {
- return vftp.create({
- host: fconfig.host,
- port: fconfig.port,
- user: fconfig.user,
- password: fconfig.pass,
- parallel: fconfig.simultaneous_connections,
- log: gutil.log
- });
- }
- gulp.task('deploy', function() {
- var conn = getFtpConnection();
- return gulp.src(fconfig.globs, { base: fconfig.local_path, buffer: false })
- .pipe( conn.newer( fconfig.remote_root ) ) // only upload newer files
- .pipe( conn.dest( fconfig.remote_root ) )
- ;
- });
- gulp.task('deploy-watch', function() {
- var conn = getFtpConnection();
- gulp.watch(fconfig.globs)
- .on('change', function(event) {
- console.log('Changes detected! Uploading file "' + event.path + '", ' + event.type);
- return gulp.src( [event.path], { base: fconfig.local_path, buffer: false } )
- .pipe( conn.newer( fconfig.remote_root ) ) // only upload newer files
- .pipe( conn.dest( fconfig.remote_root ) )
- ;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement