Dimitri Mestdagh
Dimitri Mestdagh

Reputation: 44755

grunt-contrib-compress exclude dot folder

I'm using the grunt-contrib-compress task to compress the contents of the dist/ folder inside a ZIP archive. To do that I'm using the following configuration:

compress: {
  dist: {
    options: {
      archive: 'dist/<%= pkg.name %>-<%= pkg.version %>.zip'
    },
    files: [{
      cwd: 'dist/',
      expand: true,
      src: [ '**' ]
    }]
  }
},

This is working great (all files are zipped), however, it also adds a folder called ".". I suppose that it's there because I'm including **, which also includes the current folder (a single dot).

For example:

enter image description here

Is there a way to prevent this folder to be added to the ZIP?

I tried adding !. to my src but that did not seem to do the trick. I also read about the dot property, but setting it to false did not help either.

Upvotes: 2

Views: 1183

Answers (1)

raidendev
raidendev

Reputation: 2809

You need src: ['**/*'] because ** in minimatch is a "Globstar" matcher, it matches everything including directory itself (the dot-directory). However, pattern **/* means "include all files and subdirectories" but dot-directory neither subdirectory nor file and it does not match it.

Upvotes: 3

Related Questions