extract-zip
Unzip written in pure JavaScript. Extracts a zip into a directory. Available as a library or a command line program.
Uses the yauzl ZIP parser.
Installation
Get the library:
npm install extract-zip --save
Install the command line program:
npm install extract-zip -g
JS API
var extract = require('extract-zip')
extract(source, {dir: target}, function (err) {
// extraction is complete. make sure to handle the err
})
Options
dir- defaults toprocess.cwd()defaultDirMode- integer - Directory Mode (permissions) will default to493(octal0755in integer)defaultFileMode- integer - File Mode (permissions) will default to420(octal0644in integer)onEntry- function - if present, will be called with(entry, zipfile), entry is every entry from the zip file forwarded from theentryevent from yauzl.zipfileis theyauzlinstance
Default modes are only used if no permissions are set in the zip file.
CLI Usage
extract-zip foo.zip <targetDirectory>
If not specified, targetDirectory will default to process.cwd().
Source
| 1 | # extract-zip |
| 2 | |
| 3 | Unzip written in pure JavaScript. Extracts a zip into a directory. Available as a library or a command line program. |
| 4 | |
| 5 | Uses the [`yauzl`](http://npmjs.org/yauzl) ZIP parser. |
| 6 | |
| 7 | [](https://nodei.co/npm/extract-zip/) |
| 8 | [](https://github.com/feross/standard) |
| 9 | [](https://travis-ci.org/maxogden/extract-zip) |
| 10 | |
| 11 | ## Installation |
| 12 | |
| 13 | Get the library: |
| 14 | |
| 15 | ``` |
| 16 | npm install extract-zip --save |
| 17 | ``` |
| 18 | |
| 19 | Install the command line program: |
| 20 | |
| 21 | ``` |
| 22 | npm install extract-zip -g |
| 23 | ``` |
| 24 | |
| 25 | ## JS API |
| 26 | |
| 27 | ```js |
| 28 | var extract = require('extract-zip') |
| 29 | extract(source, {dir: target}, function (err) { |
| 30 | // extraction is complete. make sure to handle the err |
| 31 | }) |
| 32 | ``` |
| 33 | |
| 34 | ### Options |
| 35 | |
| 36 | - `dir` - defaults to `process.cwd()` |
| 37 | - `defaultDirMode` - integer - Directory Mode (permissions) will default to `493` (octal `0755` in integer) |
| 38 | - `defaultFileMode` - integer - File Mode (permissions) will default to `420` (octal `0644` in integer) |
| 39 | - `onEntry` - function - if present, will be called with `(entry, zipfile)`, entry is every entry from the zip file forwarded from the `entry` event from yauzl. `zipfile` is the `yauzl` instance |
| 40 | |
| 41 | Default modes are only used if no permissions are set in the zip file. |
| 42 | |
| 43 | ## CLI Usage |
| 44 | |
| 45 | ``` |
| 46 | extract-zip foo.zip <targetDirectory> |
| 47 | ``` |
| 48 | |
| 49 | If not specified, `targetDirectory` will default to `process.cwd()`. |
