grunt-contrib-clean to remove all folders/files except for one folder and its contents
gruntjs, javascript, node.js
Solution
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!
Problem
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.