Saturday 15 May 2010

Gulp copy flatten only one sub folder -



Gulp copy flatten only one sub folder -

i have directory structure

|__apps | |__app1 | |__dist | |__sub | |__** | |__** | |__app2 | |__dist | |__**

my current code

gulp.task('move', function() { gulp.src('./apps/{app1,app2}/dist/**/*') .pipe(gulp.dest('./dist')); });

but make

|__dist | |__app1 | |__dist | |__sub | |__** | |__** | |__app2 | |__dist | |__**

and want re-create construction (flatten dist folder when re-create app1 , app2)

|__dist | |__app1 | |__sub | |__** | |__** | |__app2 | |__**

my solution plugin 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')); });

gulp

No comments:

Post a Comment