Asif Mahmood
Asif Mahmood

Reputation: 1

Skip sub-directories using grunt-clean

I am writing a grunt-contrib-clean script and want to delete all the sub-directories in a directory excluding two directories. Following is the directory structure:

/resources/nls/ar
/resources/nls/ar-AE
/resources/nls/ca
/resources/nls/ca-ES
/resources/nls/en
/resources/nls/en-US
/resources/nls/localeElements.js

and so on for all the locales.

I want to keep only the en, en-US directories and the file localeElements.js. I am using the following Grunt script. The single file in "nls" folder is not deleted as desired. But it deletes all the folders inside including the en & en-US folders which I don't want. Please guide and help.

clean: {
  postBuildSizeReduction: [
    '!../resources/nls/en/**',
    '!../resources/nls/en-US/**',
    '../resources/nls/*/'
  ]
}

Upvotes: 0

Views: 64

Answers (1)

fubar
fubar

Reputation: 17378

Change the order of the directories listed, so that the deletions come first, followed by the exclusions.

clean: {
    postBuildSizeReduction: [
        '../resources/nls/',
        '!../resources/nls/en', 
        '!../resources/nls/en-US'
    ]
}

Upvotes: 1

Related Questions