Search code examples
node.jsgulp

Copy folder with it's content in gulp


I have a folder node_modules which contains @bower_components folder, jquery-powertip folder and other folders.

Using a gulp task I want to copy the content of the @bower_components folder and the jquery-powertip folder with it's content to a destination folder.

The problem I'm facing is copying the jquery-powertip folder with it's content.

I tried as following :

gulp.task('move-dependencies', function () {
    return gulp.src(['node_modules/@bower_components/**', 'node_modules/jquery-powertip'])
               .pipe( gulp.dest(src + '/bower_components') );
});

But this will only copy the jquery-powertip folder without it's content.

I tried this too :

gulp.task('move-dependencies', function () {
    return gulp.src(['node_modules/@bower_components/**', 'node_modules/jquery-powertip/**'])
               .pipe( gulp.dest(src + '/bower_components') );
});

But this will copy the content of the jquery-powertip folder to the target folder destination (I'm not getting the "jquery-powertip" folder in target, just its contents)

So how can I solve this ?


Solution

  • I would do it like this:

    gulp.task('move-dependencies', function () {
        var task1 = gulp.src(['node_modules/@bower_components/**'])
                    .pipe( gulp.dest(src + '/bower_components') );
        var task2 = gulp.src(['node_modules/jquery-powertip/**'])
                    .pipe( gulp.dest(src + '/bower_components/jquery-powertip') );
        return [ task1, task2 ]; // or merge(task1, task2);
    });