Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No clear way to clean-up files using gulp #2826

Open
andrienko opened this issue Dec 22, 2024 · 0 comments
Open

No clear way to clean-up files using gulp #2826

andrienko opened this issue Dec 22, 2024 · 0 comments

Comments

@andrienko
Copy link

andrienko commented Dec 22, 2024

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));
}

image

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.

@andrienko andrienko changed the title A clear way to clean-up files using gulp No clear way to clean-up files using gulp Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant