gulp icon indicating copy to clipboard operation
gulp copied to clipboard

Gulp square brackets [] match on different OS

Open iliyahanev opened this issue 4 years ago • 2 comments

This is actually not a bug, however this has taken several days of my time to find it work.

This could be used to update your docs for people who are trying to match files/folders with square brackets in their names.

// MAC / LINUX OS
function minifyJs() {
 return gulp.src('resources/\\[testFolder\\]/**/*.js') // note the \\[name\\] escape here
 .pipe(minify({ noSource: true }))
 .pipe(gulp.dest('resources/[testFolder]')) // this is working for both
}

// WINDOWS 10
function minifyJs() {
 return gulp.src('resources/[[]testFolder]/**/*.js') // note [[]name] escape here
  .pipe(minify({ noSource: true }))
  .pipe(gulp.dest('resources/[testFolder]')) // this is working for both
}

My original article in stack-overflow: https://stackoverflow.com/questions/61442043/gulp-src-match-folder-with-square-brackets/61443677?noredirect=1#comment108764225_61443677

iliyahanev avatar Apr 28 '20 17:04 iliyahanev

In gulp 4, we tried to normalize the escaping of globs. This shouldn't require different escape patterns.

phated avatar Apr 28 '20 17:04 phated

Hello, yes, I am using the latest versions of gulp, node, npx Windows 10 Gulp CLI version: 2.2.0 Gulp Local version: 4.0.2 Node: v10.16.0

And it still didn't work for me. This is the reason I created this because I believe there's another fan of gulp who could meet this problem and it isn't documented.

iliyahanev avatar Apr 28 '20 19:04 iliyahanev

This will be fixed in gulp v5 via glob-stream v8. See https://github.com/gulpjs/glob-stream/pull/117 for more information.

phated avatar Jan 03 '23 23:01 phated