Description
The recipe 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)
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:
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.