No clear way to clean-up files using gulp
- Dominant language
- JavaScript
- Stars
- 32.9k
- Forks
- 4.1k
- PR merge metrics
- No merged PRs in 30d
Description
The [recipe](https://github.com/gulpjs/gulp/blob/master/docs/recipes/delete-files-folder.md) states, that users got to use `del` package to delete files. Packages I used previously for that, `gulp-clean` and `gulp-rimraf` are now both deprecated in favor of the metod described in the recipe.
First of all, the recipe needs to be updated, as `del` package now uses ESM, which exposes two exports - `deleteSync` or `deleteAsync`. Which one should be used?
Secondly, when I try to delete files using `vinyl-paths` method - I get an error (With both syna and async expoerts. A race condition? Is that a bug or desired behavior?.. `gulp-clean` and `gulp-rimraf` also give me this error now, at least on Windows).
(note that I want to ignore some of the files)
```javaScript
import { folders } from '../config.mjs';
import { src } from 'gulp';
import vinylPaths from 'vinyl-paths';
import { deleteAsync } from 'del';
export default function clean() {
return src([
`${folders.result}/**/*`,
`!${folders.result}/favicon.ico`,
`!${folders.result}/assets`
], { read: false }).pipe(vinylPaths(deleteAsync));
}
```

So, I did not find an easy way to delete files in a stream.
This way it works:
```javaScript
import { folders } from '../config.mjs';
import { deleteAsync } from 'del';
export default function clean() {
return deleteAsync([`${folders.result}/**/*`, `!${folders.result}/favicon.ico`, `!${folders.result}/assets`]);
}
```
...but I need to use it via `gulp.src` (as I want to exclude files from deletion in a predictable way), and there is no clear way.
Contributor guide
Assessment
This issue has not been assessed yet.