Moving the directories themselves
Based on Use gulp to select and move directories and their files, use ./
for the base
option and make sure the paths are correct:
var files = [
'./app/**/*.*',
'./bin/**/*.*',
'./src/**/*.*',
'./tests/**/*.*',
'./var/',
'./vendor/',
'./composer.json'
];
gulp.task('distribute', function() {
return gulp.src(files , { base: './' })
.pipe(gulp.dest('dist'));
});
Moving the files within each directories
Don't use the base
option and change your paths a little.
var files = [
'app/**/*.*',
'bin/**/*.*',
'src/**/*.*',
'tests/**/*.*',
'var/',
'vendor/',
'composer.json'
];
gulp.task('distribute', function() {
return gulp.src(files)
.pipe(gulp.dest('./dist'));
});
Flexible way to threat each directory as a task
If you want to move the folder themselves, just make a task for each one using a task generator function.
function moveDirTask(dir, dest) {
return function() {
return gulp.src(`${dir}/**/*`)
.pipe(gulp.dest(`${dest}/${dir}/`));
};
}
gulp.task('move-app', moveDirTask('app', 'dest'));
gulp.task('move-bin', moveDirTask('bin', 'dest'));
gulp.task('move-src', moveDirTask('src', 'dest'));
gulp.task('move-tests', moveDirTask('tests', 'dest'));
// etc.
gulp.task('distribute', [
'move-app',
'move-bin',
'move-src',
'move-tests'
// etc.
], function() {
return gulp.src('composer.json')
.pipe(gulp.dest('dest'));
});