gulp
gulp copied to clipboard
Exclude path from src not working ('!../folder')?
Why is this '!../frontend/admin/modules/login/*.scss'
ignored from the gulp.src([ … ])
list?
And by ignored I mean it still gets included ; )
The file globing is one of the core components of Gulp. A bug is still possible, but it is likely to be a configuration error. If you wish to report a bug, you need to use the issue template. Without this information it is hard to act on your report.
What were you expecting to happen? Expected excluded files in gulp.src to be excluded
What actually happened? Excluded files with ../ where not excluded on Mac/Linux, seems to work on Windows
Please post a sample of your gulpfile (preferably reduced to just the bit that's not working)
gulp.task('jshint', function () {
return gulp.src([
'../src/app/scripts/**/*.js',
'!../src/app/scripts/**/*.spec.js'
])
.pipe(plugins.jshint())
.pipe(plugins.jshint.reporter('default'));
});
What version of gulp are you using? 4.0.0
What versions of npm and node are you using? npm 6.2.0 node 10.9.0
I fixed my issue by moving the gulpfile to the root level, and made a bit of rearranging to avoid the ../
part of the path.
Can also be done with gulp.src cwd option
gulp.src([ 'src/app/scripts/**/*.js', '!src/app/scripts/**/*.spec.js' ], { cwd: '../'});
But I'd prefer not to rewrite all my scripts
I am unable to replicate this. Can someone provide a repository and specific instructions on how to reproduce?
I am unable to require in gulpfile.js the separate tasks in different .js files
@42tte thanks, worked for me
Created a repository that could be used for reproduction: https://github.com/marius-klimantavicius/gulp-repro-2211
As mentioned before - it does work correctly in Windows. For me it fails when being run in linux docker container (haven't tested full linux vm though).
To reproduce 1:
npm install
in /app
npx gulp build
in /app
or
docker build .
in /
Expected result: *.spec.js
file names are not printed to console.
Actual result: *.spec.js
file name is printed but only from parent glob.
Oh my god, this was killing me, couldn't figure out why the heck the negation didn't work for me and then I came across this. Sheesh. I'm on Ubuntu Linux 18.04. The cwd trick did it for me.
Just experienced this today... Gulp4. Following @42tte workaround worked, also don't wanna rewrite everything. Thanks @42tte
Thanks @42tte!
Hello, a little question anyway: is it a bug or a feature since it was not working the same on Gulp v3? Thanks for your support!
negation is not working for me on Windows. Or perhaps I am not doing it right and the documentation needs to be improved. My folder structure /root/project1/[html | src | etc] /root/build/preprocess/gulpfile.js
The following line does exclude all the contents within src: (project.directory is a relative path from the gulpfile: "../../*")
gulp.src([
`${project.directory}/**`,
`!${project.directory}/src/**`,
])
However, doing something like:
let task = gulp.src([
`${project.directory}/**`,
`!${project.directory}/src/*.js`,
])
or
let task = gulp.src([
`${project.directory}/**`,
`!${project.directory}/src/**/*.js`,
])
or
let task = gulp.src([
`${project.directory}/**`,
`!${project.directory}/src/**.js`,
])
does not work.
This will be fixed in gulp v5 via glob-stream v8. See https://github.com/gulpjs/to-absolute-glob/pull/2 for more information.