EmptyData
EmptyData

Reputation: 2576

In grunt , how to exclude .git folder from clean in dist folder

Currently my code is:

clean: {
      dist: {
        files: [{
          dot: true,
          src: [
            '.tmp',
            '<%= yeoman.dist %>/{,*/}*',
            '!<%= yeoman.dist %>/.git/**'
          ]
        }]
      },
      server: '.tmp'
    },

But it is still deleting .git folder in dist folder.

Upvotes: 2

Views: 268

Answers (1)

bosch
bosch

Reputation: 1129

Just ignoring the .git in src array should avoid deleting it.
The following task works for me (before section):

clean: {
        before: {
            src: ['dist/**/*', '!dist/.git/**', '!dist/.gitignore', 'temp'] //do not clean the git folder
        },
        after: {
            src: ['temp']
        }
    },

The clean task above clears the entire contents of the dist and temp folders except for what's inside dist/.git folder and the dist/.gitignore file.

I use this task as part of the build and deployment flow and it works fine, I keep my commits after each build&deploy although the dist folder is cleaned (without .git's).

Hope this helps someone!

Upvotes: 1

Related Questions