Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ module.exports = function (zipPath, opts, cb) {
opts.onEntry(entry)
}

var dest = path.join(opts.dir, entry.fileName)
var strip = opts.strip || 0
var filenameParts = entry.fileName.split('/')
filenameParts = filenameParts.slice(Math.min(strip, filenameParts.length - 1))
var destParts = [opts.dir].concat(filenameParts)
var dest = path.join.apply(path, destParts)

// convert external file attr int into a fs stat mode int
var mode = (entry.externalFileAttributes >> 16) & 0xFFFF
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ extract(source, {dir: target}, function (err) {
- `defaultDirMode` - integer - Directory Mode (permissions) will default to `493` (octal `0755` in integer)
- `defaultFileMode` - integer - File Mode (permissions) will default to `420` (octal `0644` in integer)
- `onEntry` - function - if present, will be called with every entry from the zip file. forwarded from the `entry` event from yauzl.
- `strip` - integer - number of leading directory components to remove from extracted files.

Default modes are only used if no permissions are set in the zip file.

Expand Down