grunt-contrib-clean
grunt-contrib-clean copied to clipboard
Skipping files seems broken
The following configuration does not skip the js/main.js
file:
{
clean: {
js: ['js/', '!js/main.js']
}
}
Is it intented ?
:+1: I am hitting this as well
clean: {
dest: ['<%= config.dest %>/**', '!<%= config.dest %>/CNAME']
}
Note that skipping files seems to work fine when using a destination path with extensions, but doesn't skip files when destination path matches a directory. My expectation was that a directory shouldn't be cleaned if it contains an excluded file.
Same here! I want to prevent clean to remove files into bower_components folder, but it does not skip it.
clean: {
dev: [
'<%= globalConfig.src %>/**/*.js',
'<%= globalConfig.src %>/**/*.map',
'!<%= globalConfig.src %>/**/bower_components/*.*'
]
}
Any idea ?
Same issue with this:
[
'./WebContent/scripts/**/*',
'!./WebContent/scripts/views/**/*'
]
:+1:
There is no code in clean.js
that deals with exclusion.
But yes, I'd like to see that as well. Either that or please fix the documentation accordingly.
@Vadorequest You may be able to achieve exclusion of sub-directory with something like this instead:
[
'./WebContent/scripts/**/*.*',
'!./WebContent/scripts/views/**/*'
]
The problem with your original is that the first rule, ./WebContent/scripts/**/*
, was including the views
directory in deletes, which overrides the exclusions for anything under that directory, as @jt000 noticed. To work around this, you can mandate an extension via *.*
, which should work as long as all the files in your scripts
have extensions—otherwise, you'll need glob rules more specific to your project.
To prove that this works, see the excludeSub
test case I've added in d642845 on adjohnson916/grunt-contrib-clean#exclude.
For @Nemikolh's case, I'd try matching not the js
directory, but any files under it:
['js/**/*.*', '!js/main.js']
For @milton-rodriguez-uruit's case, I'd try matching any files under bower_components
deeply:
[
'<%= globalConfig.src %>/**/*.js',
'<%= globalConfig.src %>/**/*.map',
'!<%= globalConfig.src %>/**/bower_components/**/*.*'
]
This is a pretty frustrating issue! Anybody know of an alternative plugin that allows this?
Any news about this bug?
Took me some time to find this. Please fix it.
Same issue, will require some super janky code until fixed.
My case:
theme: ["public/wp-content/themes/my-theme/*", "!public/wp-content/themes/my-theme/acf-json/"]
I want to remove everything in my-theme but keep everything in acf-json. This rule simply removes everything in my-theme.
This being still open means someone needs to update the .md file, the answer can be found in this old issue thread: https://github.com/gruntjs/grunt-contrib-clean/issues/15
Specifically the reply from https://coderwall.com/p/fkdyag helped me.
theme: ["public/wp-content/themes/my-theme/*", "!public/wp-content/themes/my-theme/acf-json/"]
changed to:
theme: ["!public/wp-content/themes/my-theme/**", "public/wp-content/themes/my-theme/*", "!public/wp-content/themes/my-theme/acf-json/"]
Should work, or in the OPs simpler question
{ clean: { js: ['!js/**', 'js/*', '!js/main.js'] } }