Glob /* doesn't match files starting with dot
Asked Answered
M

2

19

I'm using gulp to copy all files from one dir to another using code like this:

gulp.src([ 'app/**/*' ]).pipe(gulp.dest('dist'));

Glob docs say * match all files, but in fact files which have names starting with dot, like .gitignore, are not copied.

How can it be worked around?

Maravedi answered 9/4, 2015 at 8:47 Comment(0)
D
40

If you add the option dot: true, it should work. Eg:

gulp.task('something', function () {
    return gulp.src([ 'app/**/*' ], {
        dot: true
    }).pipe(gulp.dest('dist'));
});

Reference

Damocles answered 9/4, 2015 at 8:58 Comment(0)
P
2

For instances where the glob pattern is the only available interface. This pattern will do the trick:

**/{,.,.*/**/,.*/**/.}*

This expands to become the following globs:

**/*
**/.*
**/.*/**/*
**/.*/**/.*

You can add app to the beginning for app/**/{,.,.*/**/,.*/**/.}*.

Psychopathy answered 10/11, 2022 at 16:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.