twolfson / grunt-zip

Zip and unzip files via a grunt plugin
MIT License
87 stars 19 forks source link

cwd and router breaks filepath #13

Closed mlaccetti closed 11 years ago

mlaccetti commented 11 years ago

Seems that when you use cwd and the router the path still shows up in the zip.

If I have:

app/js/...
app/bork.html
app/Thumbs.db

If I put a router to ignore Thumbs.db and use cwd: 'app' I'll get app/... (minus Thumbs.db).

twolfson commented 11 years ago

Unfortunately, this is expected behavior. Under the hood, cwd creates a router via path.relative. When router is provided, we don't look for cwd and continue.

The reason for this boils down to: If both cwd and router are provided, which is run first?

There are two possibilities and while one may have convention, I do not wish to muddy the waters by choosing a side. Each has an argument:

I will add an assert in the code and update the README to warn people appropriately.

As for yourself, you have a couple of options:

{
  'grunt-zip': {
    // Whitelist format
    app: {
      src: ['app/js/**/*', 'app/bork.html'],
      dest: 'app.zip'
    },

    // Blacklist format
    app2: {
      src: ['app/**/*', '!app/Thumbs.db'],
      dest: 'app2.zip'
    }
  }
}

http://gruntjs.com/configuring-tasks#globbing-patterns

https://github.com/isaacs/minimatch#comparisons-to-other-fnmatchglob-implementations

twolfson commented 11 years ago

Released assert and README.md updates in 0.9.1.

mlaccetti commented 11 years ago

Thanks for the detailed info and the solution - I'll migrate to using that. :+1: