我有目录结构
|__apps
| |__app1
| |__dist
| |__sub
| |__**
| |__**
| |__app2
| |__dist
| |__**
我当前的代码
gulp.task('move', function() {
gulp.src('./apps/{app1,app2}/dist/**/*')
.pipe(gulp.dest('./dist'));
});
但是它的制作
|__dist
| |__app1
| |__dist
| |__sub
| |__**
| |__**
| |__app2
| |__dist
| |__**
我想将此结构复制到(复制app1和app2时展平dist文件夹)
|__dist
| |__app1
| |__sub
| |__**
| |__**
| |__app2
| |__**
答案 0 :(得分:2)
我的解决方案是插件gulp-rename
gulp.task('move', function() {
gulp.src('./apps/{' + apps.join(',') + '}/dist/**/*')
.pipe($.rename(function(path) {
var parts = path.dirname.split('/');
parts.splice(1, 1);
path.dirname = parts.join('/');
}))
.pipe(gulp.dest('dist'));
});