具体代码如下:

    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);

    1. const globs = [
    2. basePath + '/CRM.*.dll',
    3. basePath + '/CrmStand.dll',
    4. basePath + '/Hsort.*.dll',
    5. basePath + '/SanGuan.dll',
    6. basePath + '/ECIF.dll',
    7. basePath + '/DataAccess.dll',
    8. ]
    9. // using base = '.' will transfer everything to /public_html correctly
    10. // turn off buffering in gulp.src for best performance
    11. return gulp.src(globs, {
    12. base: basePath,
    13. buffer: false
    14. })
    15. .pipe(filter(myFilter))
    16. .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