UNPKG

912 BJavaScriptView Raw
1/**
2 * 自动 FTP 部署任务
3 * @author lukezhu
4 * @date 2016-03-24
5 */
6
7var combiner = require('stream-combiner2');
8var vfs = require('vinyl-fs');
9var vftp = require('vinyl-ftp');
10var vpath = require('vinyl-paths');
11var readline = require('readline-sync');
12
13module.exports = function(gulp, $, conf) {
14 gulp.task('deploy', function() {
15 if (conf.ftp.pass === '') {
16 conf.ftp.pass = readline.question('Type your ftp server\'s password: ');
17 }
18
19 // ftp 配置信息
20 var ftpSvr = vftp.create({
21 host : conf.ftp.host,
22 user : conf.ftp.user,
23 password : conf.ftp.pass,
24 port : conf.ftp.port,
25 parallel : 5,
26 log : $.util.log,
27 });
28
29 vfs.src([conf.parsePwd([conf.dist, '/**'].join(''))], { buffer: false })
30 .pipe(ftpSvr.dest(conf.ftp.path));
31 });
32}