gulpjs / gulp

A toolkit to automate & enhance your workflow

Home Page:https://gulpjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gulp does not work if base path has brackets [ ]

MischaVreeburg opened this issue · comments

What were you expecting to happen?

When executing a gulp task

gulp.src('dist/js/**/*.js')
.pipe(gulp.dest('wwwroot/assets')

the task failed. When I used gulp-debug it reported no items found even though they were there and I can find them using

const glob = require("glob");
var glb = glob.sync('dist/js/**/*.js')
console.log(glb);

this listed the files correctly

I expected the gulp task to copy the files from the dist/js folder to the wwwroot/assets folder.

What actually happened?

Nothing happened.
After much debugging, I finally discovered that the issue is the the basepath.
If the basepath is something like 'c:\users\myname\projects[currentCompany]\webproject'
and I execute the gulp task in this path, nothing happens.
When I changed the basepath to 'c:\users\myname\projects\currentCompany\webproject'
the gulp task worked like it should.

Please change the globbing to deal with paths that have the [] brackets.

I would expect that gulp would work with every legal path.

The issue you are encountering is that square bracket have a special meaning in glob patterns. They are often used to match a single character, i.e. folder[123] will match folder1 but not folder4.

If you want to match projects[currentCompany], you need to escape the brackets. i.e.

src('projects\\[currentCompany\\]')