Open bcowgill opened 7 years ago
note, was using 'build/*/' as the match pattern. switching to just 'build' solves the immediate problem.
I have a related problem -- I'm using Gulp 4, I'm trying to call delete on a directory that may or may not be present, and I'm getting:
[15:13:00] Error: File not found with singular glob: /home/pat/gop/src/github.com/nullbio/lolwtf/dist/public/assets/
at Glob.<anonymous> (/home/pat/gop/src/github.com/nullbio/lolwtf/node_modules/glob-stream/index.js:41:11)
at Glob.g (events.js:291:16)
at emitOne (events.js:96:13)
at Glob.emit (events.js:188:7)
at Glob._finish (/home/pat/gop/src/github.com/nullbio/lolwtf/node_modules/glob/glob.js:172:8)
at done (/home/pat/gop/src/github.com/nullbio/lolwtf/node_modules/glob/glob.js:159:12)
at Glob._processSimple2 (/home/pat/gop/src/github.com/nullbio/lolwtf/node_modules/glob/glob.js:652:12)
at /home/pat/gop/src/github.com/nullbio/lolwtf/node_modules/glob/glob.js:640:10
at Glob._stat2 (/home/pat/gop/src/github.com/nullbio/lolwtf/node_modules/glob/glob.js:736:12)
at lstatcb_ (/home/pat/gop/src/github.com/nullbio/lolwtf/node_modules/glob/glob.js:728:12)
The dist
folder in my glob there that you can see (and naturally all of its subfolders) have the potential of not being created yet.
Is there some way I can ignore the error message, or prevent it from happening? I tried on('error'), but that doesn't seem to get fired.
It's been a while since I have touched this, but as quite a few are clearly still using gulp-clean, I'll try to be more active.
it seems the deletion of build/x gets rid of everything and when clean tries to delete build/x/this.js it gives an error.
@bcowgill I created a similar case as yours:
'use strict';
const gulp = require('gulp');
const clean = require('gulp-clean');
gulp.task('clean', () => {
return gulp.src('build/**/*')
.pipe(clean());
});
I can confirm that filepaths gulp-clean receives are the ones you mentioned:
But in my case the cleaning works and gulp-clean does not emit errors:
$ node -v
v9.3.0
$ gulp -v
[21:29:52] CLI version 2.0.0
[21:29:52] Local version 4.0.0
$ gulp clean
[21:29:56] Using gulpfile ~/gulpfile.js
[21:29:56] Starting 'clean'...
[21:29:56] Finished 'clean' after 45 ms
Why it actually works, is because of rimraf
handles ENOENT errors behind the scenes and returns successfully. Thus even when gulp-clean tries to remove a file which does not exist anymore everything should work nicely. See the rimraf
README.
@bcowgill can you provide a reproducible example of your problem? Thanks.
@nullbio I am not sure your case actually relates to gulp-clean as gulp-clean does not try to find files with a glob. Most likely this happens already before the execution comes to the gulp-clean plugin. But to be sure could you provide more details or a simplified example where your error occurs? Thanks.
I know that this is kinda old thread, but for those who are facing @nullbio problem with gulp 4:
passing allowEmpty: true
to gulp.src should solve the problem.
gulp.task("clean", function() {
return gulp.src("./dist", { read: false, allowEmpty: true })
.pipe(gulpClean());
});
gulp-clean gets the listing of files to delete:
build/x build/x/this.js
it seems the deletion of build/x gets rid of everything and when clean tries to delete build/x/this.js it gives an error. WHY? it's already gone! Perhaps clean should sort the list in reverse length order before doing its work or have an option to ignore / warn on files that are missing.