gulp-unzip
Advanced tools
Comparing version 1.0.0 to 1.0.1
57
index.js
@@ -1,9 +0,7 @@ | ||
var through = require('through2'); | ||
var unzip = require('unzipper') | ||
var fs = require('fs') | ||
var defaults = require('defaults') | ||
var fancyLog = require('fancy-log') | ||
var Vinyl = require('vinyl') | ||
const through = require('through2').obj, | ||
unzip = require('unzipper'), | ||
Vinyl = require('vinyl'); | ||
module.exports = function(options){ | ||
module.exports = (options = {}) => { | ||
function transform(file, enc, callback){ | ||
@@ -15,37 +13,30 @@ if (file.isNull()) { | ||
var opts = {}; | ||
options = options || {}; | ||
opts.filter = options.filter || function () { return true; }; | ||
const opts = {}; | ||
opts.filter = options.filter || (() => true); | ||
opts.keepEmpty = options.keepEmpty || false; | ||
// unzip file | ||
var self = this | ||
file.pipe(unzip.Parse()) | ||
.on('entry', function(entry){ | ||
var chunks = [] | ||
.on('entry', entry => { | ||
const chunks = []; | ||
if(!opts.filter(entry)){ | ||
entry.autodrain() | ||
// skip entry | ||
return | ||
entry.autodrain(); | ||
return; | ||
} | ||
entry.pipe(through.obj(function(chunk, enc, cb){ | ||
// fancyLog("Find file: "+ entry.path) | ||
chunks.push(chunk) | ||
cb() | ||
}, function(cb){ | ||
if(entry.type == 'File' && (chunks.length > 0 || opts.keepEmpty)){ | ||
self.push(new Vinyl({ | ||
entry.pipe(through((chunk, enc, cb) => { | ||
chunks.push(chunk); | ||
cb(); | ||
}, cb => { | ||
if(entry.type === 'File' && (chunks.length > 0 || opts.keepEmpty)){ | ||
this.push(new Vinyl({ | ||
cwd : "./", | ||
path : entry.path, | ||
contents: Buffer.concat(chunks) | ||
})) | ||
})); | ||
} | ||
cb() | ||
})) | ||
}).on('close', function(){ | ||
callback() | ||
}) | ||
cb(); | ||
})); | ||
}).on('close', callback); | ||
} | ||
return through.obj(transform); | ||
} | ||
return through(transform); | ||
}; |
{ | ||
"name": "gulp-unzip", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "gulp plugin for unzip", | ||
@@ -8,3 +8,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/inuscript/gulp-unzip.git" | ||
"url": "https://github.com/terrierscript/gulp-unzip.git" | ||
}, | ||
@@ -20,17 +20,45 @@ "scripts": { | ||
], | ||
"author": "inuscript", | ||
"author": { | ||
"name": "terrierscript", | ||
"url": "https://github.com/terrierscript" | ||
}, | ||
"contributors": [ | ||
{ | ||
"name":"Joey Cozza", | ||
"url": "https://github.com/joeycozza" | ||
},{ | ||
"name":"Joe Pettersson", | ||
"url": "https://github.com/Joe8Bit" | ||
},{ | ||
"name":"Erik Vold", | ||
"url": "https://github.com/erikvold" | ||
},{ | ||
"name":"hami", | ||
"url": "https://github.com/hami-jp" | ||
},{ | ||
"name":"Selwyn", | ||
"url": "https://github.com/Siilwyn" | ||
},{ | ||
"name":"João Moreno", | ||
"url": "https://github.com/joaomoreno" | ||
},{ | ||
"name":"Evan Oxfeld", | ||
"url": "https://github.com/EvanOxfeld" | ||
},{ | ||
"name": "Ulises Gascón", | ||
"url": "https://github.com/ulisesGascon" | ||
} | ||
], | ||
"license": "BSD-2-Clause", | ||
"dependencies": { | ||
"defaults": "^1.0.0", | ||
"fancy-log": "^1.3.2", | ||
"through2": "^0.4.1", | ||
"unzipper": "^0.7.1", | ||
"vinyl": "^1.2.0" | ||
"through2": "3.0.0", | ||
"unzipper": "0.9.10", | ||
"vinyl": "1.2.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "^1.18.0", | ||
"assert-plus": "^0.1.5", | ||
"gulp-concat": "^2.2.0", | ||
"minimatch": "^0.2.14" | ||
"mocha": "5.2.0", | ||
"assert-plus": "1.0.0", | ||
"gulp-concat": "2.6.1", | ||
"minimatch": "3.0.4" | ||
} | ||
} |
@@ -1,7 +0,18 @@ | ||
[![travis](https://travis-ci.org/inuscript/gulp-unzip.svg)](https://travis-ci.org/inuscript/gulp-unzip) | ||
[![travis](https://travis-ci.org/terrierscript/gulp-unzip.svg)](https://travis-ci.org/terrierscript/gulp-unzip) | ||
![dependencies](https://img.shields.io/david/terrierscript/gulp-unzip.svg) | ||
![devDependencies](https://img.shields.io/david/dev/terrierscript/gulp-unzip.svg) | ||
![Downloads per Week NPM](https://img.shields.io/npm/dw/gulp-unzip.svg) | ||
![Open PRs](https://img.shields.io/github/issues-pr/terrierscript/gulp-unzip.svg) | ||
![Open Issues](https://img.shields.io/github/issues-raw/terrierscript/gulp-unzip.svg) | ||
# gulp-unzip | ||
> gulp plugin for unzip file. | ||
# Usage | ||
### Usage | ||
```bash | ||
npm install gulp-unzip --save | ||
``` | ||
```js | ||
@@ -16,5 +27,5 @@ var unzip = require('gulp-unzip') | ||
# Options | ||
### Options | ||
## filter | ||
#### filter | ||
@@ -39,3 +50,3 @@ You can provide a `filter` option. It should be a function that gets an `entry` as an argument and returns `true` or `false`. | ||
## keepEmpty | ||
#### keepEmpty | ||
@@ -48,16 +59,23 @@ You can provide `true` or `false` in `keepEmpty` for whether you want to extract empty files from the archive or not. Defaults to `false`. | ||
.pipe(unzip({ keepEmpty : true })) | ||
... | ||
//... | ||
}) | ||
``` | ||
# Entry | ||
### Contributors | ||
For more info, go to [node-unzip](https://github.com/EvanOxfeld/node-unzip). | ||
If you want to contribute to the project, please check de [Contribution Guidelines](CONTRIBUTING.md) | ||
- `entry.size`, returns the file size | ||
- `entry.type`, returns `Directory` or `File` | ||
- `entry.path`, returns the file path in the zip file | ||
**Author** | ||
- [terrierscript (@terrierscript)](https://github.com/terrierscript) | ||
# Known issue | ||
- Cause `RangeError: Maximum call stack size exceeded` when open large zip file | ||
- https://github.com/inuscript/gulp-unzip/issues/2 | ||
**Maintainers** | ||
- [Ulises Gascón (@ulisesGascon)](https://github.com/ulisesGascon) | ||
**Contributors** | ||
- [Joey Cozza (@joeycozza)](https://github.com/joeycozza) | ||
- [Joe Pettersson (@Joe8Bit)](https://github.com/Joe8Bit) | ||
- [Erik Vold (@erikvold)](https://github.com/erikvold) | ||
- [hami (@hami-jp)](https://github.com/hami-jp) | ||
- [Selwyn (@Selwyn)](https://github.com/Siilwyn) | ||
- [João Moreno (@joaomoreno)](https://github.com/joaomoreno) | ||
- [Evan Oxfeld (@EvanOxfeld)](https://github.com/EvanOxfeld) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10353
3
5
79
0
36
1
+ Addedbig-integer@1.6.52(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedthrough2@3.0.0(transitive)
+ Addedunzipper@0.9.10(transitive)
+ Addedxtend@4.0.2(transitive)
- Removeddefaults@^1.0.0
- Removedfancy-log@^1.3.2
- Removedansi-gray@0.1.1(transitive)
- Removedansi-wrap@0.1.0(transitive)
- Removedbuffer-shims@1.0.0(transitive)
- Removedcolor-support@1.1.3(transitive)
- Removeddefaults@1.0.4(transitive)
- Removedfancy-log@1.3.3(transitive)
- Removedisarray@0.0.1(transitive)
- Removedobject-keys@0.4.0(transitive)
- Removedparse-node-version@1.0.1(transitive)
- Removedprocess-nextick-args@1.0.7(transitive)
- Removedreadable-stream@1.0.342.1.5(transitive)
- Removedstring_decoder@0.10.31(transitive)
- Removedthrough2@0.4.2(transitive)
- Removedtime-stamp@1.1.0(transitive)
- Removedunzipper@0.7.6(transitive)
- Removedxtend@2.1.2(transitive)
Updatedthrough2@3.0.0
Updatedunzipper@0.9.10
Updatedvinyl@1.2.0