New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add strip
option
#13
Add strip
option
#13
Conversation
I have a couple of problems here. Firstly you can't use a literal 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 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 |
Whoops, missed |
@wibblymat, should it process each file individually and check if |
@wibblymat ⬆️ |
@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 |
@wibblymat, sorry for taking such time. Should be ok now. |
@@ -96,6 +96,21 @@ DecompressZip.prototype.extract = function (options) { | |||
}); | |||
} | |||
|
|||
if (options.strip) { | |||
files = files.filter(function (file) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is should be map, not filter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, true. Fixed.
ping @wibblymat |
Fixes #13.
No description provided.