izaakschroeder / vinyl-s3

Use S3 as a source or destination of vinyl files.
20 stars 16 forks source link

destination filename is missing first character #1

Closed bkw closed 9 years ago

bkw commented 9 years ago

in my tests the first character of the destination file is dropped. I think filepath.substr in https://github.com/izaakschroeder/vinyl-s3/blob/master/lib/write-stream.js#L36 should not add +1 to the file.base.length.

izaakschroeder commented 9 years ago

So my understanding is as follows:

The generated key checks to see if you've specified a prefix; e.g. dest('/foo') means awsOptions.Key = '/foo'. Then say gulp sends vinyl file with path /bar/baz and base of /bar. Intention was originally to generate foo/baz. However if no prefix is given then you get the chopping behaviour since it becomes baz (chopping off the "/"). I believe this is expected in S3 since / should never be the first character.

Can you give me an example and result that you're seeing? I'll see if I can have a look.

bkw commented 9 years ago

I put up my example in this gist here: https://gist.github.com/bkw/3dd96f05656a7e102e74

Thanks for considering this.

izaakschroeder commented 9 years ago

No problem I'll have a look in a little bit here!

izaakschroeder commented 9 years ago

In your through2 block there can you console.log the file.base and file.path properties? I expect file.base to be /path/to/views and file.path to be /path/to/views/index.jade so that

file.path.substr(file.base.length + 1)

should produce index.jade. Clearly this is not happening.

bkw commented 9 years ago

file.base: /path/to/views/ file.path: /path/to/views/index.html

it's index.html and not .jade because of the gulp.rename earlier.

bkw commented 9 years ago

seems we should trim slashes :-)

izaakschroeder commented 9 years ago

Yes! I will get to this soon :smile:

izaakschroeder commented 9 years ago

For some definition of "soon". Pretty big refactor which I think both addresses this issue (now using file.relative) and makes the library easier to use. See updated README on homepage for new examples!