twolfson / grunt-zip

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

Router doesnt seem to work? #33

Closed keithmancuso closed 9 years ago

keithmancuso commented 9 years ago

I tried the exact task from the readme and I'm getting a "warning path is not defined" error. Also it seems like the docs are missing a comma after the router?

unzipCssOnly: {
  // If router returns a falsy varaible, the file will be skipped
  router: function (filepath) {
    // Grab the extension
    var extname = path.extname(filepath);

    // If the file is a .css, extract it
    if (extname === '.css') {
      return filepath;
    } else {
    // Otherwise, skip it
      return null;
    }
  }

  src: ['bootstrap.css'],
  dest: 'bootstrap-css/'
}

A couple of errors i think

right?

even with these changes tho i get the path error?

twolfson commented 9 years ago

Yep, sorry these were written without testing them and not segmented properly. The issue is you haven't required the path module from node. If you put this at the top of your Gruntfile, you should be fine

var path = require('path');

http://nodejs.org/api/path.html

I am on my way out the door but will leave this issue open to fix the docs properly later this week.

keithmancuso commented 9 years ago

ahh yes, that did it! Thanks so much

twolfson commented 9 years ago

Okay, I rewrote the docs to a much more understandable state in 0.16.1 and included the note about path. Thanks for the bug report!