Closed kevva closed 10 years ago
Whoops, missed path.sep
. I'll fix that and add the path depth check. As for using strip: 'some/path'
I'm in doubt. I think it's better to stick to the standard (equivalent to --strip-components
). That feature should probably go under a different option.
@wibblymat, should it process each file individually and check if options.strip
is deeper than file.path
? Or maybe you meant that it should check for the deepest path in all files and check it against options.strip
?
@wibblymat :arrow_up:
@kevva I think I meant that you check up front that each file that is going to be extracted (i.e. after the filter has been applied) is at least as deep as options.strip
@wibblymat, sorry for taking such time. Should be ok now.
ping @wibblymat
I have a couple of problems here. Firstly you can't use a literal
/
in anything to do with paths or it won't work on Windows. You need to usepath.sep
.Also, I'd like for there to be at least a warning if there are fewer path elements than the strip number. If you have a tree that only goes (for e.g.) two deep and have a
strip
of 4 then all files will end up in the same place. If two files have the same name one will overwrite the others.At https://github.com/bower/decompress-zip/blob/master/lib/decompress-zip.js#L89 you could loop through the files and check that they all have a common path prefix of the right length and error out before actually doing any extracting. You could transform the paths at that point too.
I think my preference would actually be that instead of saying
strip: 2
you should have to saystrip: "angular/dist"
. Then only files that are in that path will be extracted. But that's kind of a different feature so maybe not.