Reputation: 18248
How would you negate the cleaning of a particular folder using grunt-contrib-clean. Negating the match doesn't appear to work.
clean: {
plugins: [
'app/plugins/myplugin',
'!app/plugins/myplugin/assets'
]
}
I've tried a couple different negation patterns, such as:
'!app/plugins/myplugin/assets'
'!app/plugins/myplugin/assets/**'
as well as, reversing the positions in the array in case that mattered. Can't seem to hold onto the assets folder/contents on clean. The assets folder contains jQuery, AngularJS, and built Bootstrap (SASS), which I don't want to have to keep copying/building, seems a waste of time.
Upvotes: 5
Views: 5742
Reputation: 2983
I wanted the ability to blow away all of bower_components except for require.js. Here is how I did it in my gruntFile:
/* all bower components except require */
applicationDistHome + '/bower_components/**/*',
'!' + applicationDistHome + '/bower_components/requirejs/**',
applicationDistHome + '/bower_components/requirejs/*',
'!' + applicationDistHome + '/bower_components/requirejs/require.js',
Upvotes: 0
Reputation: 5084
I quickly set up a folder structure like you're referencing and tried the following, that works for me:
clean: {
options: {
'no-write': true
},
plugins: ['app/plugins/myplugin/**/*', '!app/plugins/myplugin/assets/**']
}
The first wildcard selects all files inside the myplugin folder and all subfolders (but not the directory myplugin
itself!), while the negation deselects the whole assets directory including all subfolders and files.
You should remove the options field for real testing, as no-write: true
is only simulating a clean but doesn't actually delete files.
Hope that helps!
Upvotes: 14