[英]Display progress bar in a gulp stream
Is there a method to display the progress bar in gulp when copying certain files? 有没有方法在复制某些文件时在gulp中显示进度条?
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. 以下是使用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));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.