具体代码如下:
const gulp = require(‘gulp’);
const ftp = require(‘vinyl-ftp’);
const logger = require(‘gulplog’);
var filter = require(‘gulp-custom-filter’);
const moment = require(‘moment’);
/*
*
@param {File} file
@returns
*/
function myFilter(file) {
const flag = moment(file.stat.mtime).isAfter(moment().add(-8, ‘hours’));
return flag;
}
//const remotePath = ‘/point/SysAdmin/bin’;
const config = {
host: ‘39.106.122.138’,
user: ‘ftp_user’,
password: ‘aXyD0BZSQT4If7gt5wnSLabbMBtATPfq’,
port: 21,
parallel: 10,
log: logger.info
}
const basePath = ‘../CrmStand/bin/Release/Publish/bin’;
function CreateGulp(remotePath) {
return function () {
const conn = ftp.create(config);
const globs = [
basePath + '/CRM.*.dll',
basePath + '/CrmStand.dll',
basePath + '/Hsort.*.dll',
basePath + '/SanGuan.dll',
basePath + '/ECIF.dll',
basePath + '/DataAccess.dll',
]
// using base = '.' will transfer everything to /public_html correctly
// turn off buffering in gulp.src for best performance
return gulp.src(globs, {
base: basePath,
buffer: false
})
.pipe(filter(myFilter))
.pipe(conn.dest(remotePath))
}
}
gulp.task(‘bin1’, CreateGulp(‘/crm/CrmStand/bin’))
gulp.task(‘bin2’, CreateGulp(‘/crm_sha/CrmStand/bin’))
gulp.task(‘bin’, [‘bin1’, ‘bin2’]);
在命令行执行:gulp bin