jussi-kalliokoski / gulp-awspublish-router

A router for defining file-specific rules with gulp-awspublish
29 stars 7 forks source link

Matching a directory breaks the example config #1

Closed geelen closed 10 years ago

geelen commented 10 years ago

Given the following config:

return gulp.src("release/**")
      .pipe($.awspublishRouter({
        cache: {
          cacheTime: 86400 // Cache for 1 day by default
        },
        routes: {
          // Passthrough everything else
          "^.+$": "$&"
        }
      }))

You get an explosion, because the first file is current/path/release/, which returns a path.relative of ''. That doesn't match the passthrough regexp, you need "^.*$": "$&" to match the empty string.

Also, the explosion could have a much better error message - right now you get a missing property routeMatcher on undefined, but it's simply that the _.find doesn't find anything. So it seems like a common-enough case.

This library is exactly what I need though, and I absolutely <3 your approach. Had not even considered that a router might be a good fit, but now it seems so simple!

Cheers, -glen.

jussi-kalliokoski commented 10 years ago

Hi Glen, sorry for the wait on this one as well!

So let's see - release/ is a directory, right? There's really no such thing as directories for S3, so I think the best alternative would be to just skip them. This would be pretty simple to implement, since Vinyl instances have an isNull() method to detect empty files / directories. WDYT?

jussi-kalliokoski commented 10 years ago

I have a PR awaiting if you think what I suggested is a workable solution to the problem. :)