大量复制空目录 [英] Gulp copying empty directories
本文介绍了大量复制空目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法告诉 gulp.src
glob只包含模式匹配中的文件(如提供'is_file'
标志)?
谢谢。
解决方案
p>
var es = require('event-stream');
var onlyDirs = function(es){
return es.map(function(file,cb){
if(file.stat.isFile()) {
return cb(null,file);
} else {
return cb();
}
});
};
// ...
var s = gulp.src(globs)
.pipe(onlyDirs(es))
.pipe(gulp.dest(folders .dest +'/'+ module.folder));
// ...
In my gulp build I've made a task that runs after all compiling, uglifying and minification has occurred. This task simply copies everything from the src into the dest directory that hasn't been touched/processed by earlier tasks. The little issue I'm having is that this results in empty directories in the dest directory.
Is there a way to tell the gulp.src
glob to only include files in the pattern matching (like providing the 'is_file'
flag)?
Thanks.
解决方案
Fixed it by adding a filter to the pipeline:
var es = require('event-stream');
var onlyDirs = function(es) {
return es.map(function(file, cb) {
if (file.stat.isFile()) {
return cb(null, file);
} else {
return cb();
}
});
};
// ...
var s = gulp.src(globs)
.pipe(onlyDirs(es))
.pipe(gulp.dest(folders.dest + '/' + module.folder));
// ...
这篇关于大量复制空目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文