简体   繁体   中英

Display progress bar in a gulp stream

Is there a method to display the progress bar in gulp when copying certain files?

gulp.task('release:step-2', function() {
    return gulp.src(config.copy_src, { dot: true })
        .pipe(gulp.dest(config.path.dest.app));
});

Here's an example of using progress-stream with Gulp.

var fs = require('fs');
var gulp = require('gulp');
var progress = require('progress-stream');

var filePath = config.copy_src;
var fileSize = fs.statSync(filePath).size;

var progressStream = progress({
  length: fileSize,
  time: 100,
  objectMode: true
});

progressStream.on('progress', function (stats) {
  console.log(Math.round(stats.percentage) + '%');
});

gulp.task('release:step-2', function () {
  return gulp.src(config.copy_surc, { dot: true })
    .pipe(progressStream)
    .pipe(gulp.dest(config.path.dest.app));
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM