Skip to content

Commit

Permalink
Merge pull request #23 from terrierscript/development
Browse files Browse the repository at this point in the history
v1.0.1
  • Loading branch information
terrierscript authored Jan 28, 2019
2 parents 50488ed + cf1dffe commit 53a84d6
Show file tree
Hide file tree
Showing 6 changed files with 306 additions and 159 deletions.
93 changes: 93 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Contributing
*This contributing guide was forked from [@PurpleBooth](https://gist.github.com/PurpleBooth/b24679402957c63ec426)*

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of other developers, or if you
do not have permission to do that, you may request the reviewer to merge it for you.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [email protected]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
The BSD 2-Clause License
Copyright © 2014 terrierscript
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
[![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
var unzip = require('gulp-unzip')
Expand All @@ -13,9 +24,9 @@ gulp.task('filter_sample', function(){
})
```

# Options
### Options

## filter
#### filter

You can provide a `filter` option. It should be a function that gets an `entry` as an argument and returns `true` or `false`.

Expand All @@ -35,26 +46,33 @@ gulp.task('filter_sample', function(){
})
```

## keepEmpty
#### keepEmpty

You can provide `true` or `false` in `keepEmpty` for whether you want to extract empty files from the archive or not. Defaults to `false`.

```js
gulp.task('filter_sample', function(){
gulp.src("./download/bootstrap-3.1.1-dist.zip")
.pipe(unzip({ keepEmpty : true }))
...
//...
})
```

# Entry
### Contributors

If you want to contribute to the project, please check de [Contribution Guidelines](CONTRIBUTING.md)

For more info, go to [node-unzip](https://github.com/EvanOxfeld/node-unzip).
**Author**
- [terrierscript (@terrierscript)](https://github.com/terrierscript)

- `entry.size`, returns the file size
- `entry.type`, returns `Directory` or `File`
- `entry.path`, returns the file path in the zip file
**Maintainers**
- [Ulises Gascón (@ulisesGascon)](https://github.com/ulisesGascon)

# Known issue
- Cause `RangeError: Maximum call stack size exceeded` when open large zip file
- https://github.com/inuscript/gulp-unzip/issues/2
**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)
57 changes: 24 additions & 33 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,50 +1,41 @@
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){
if (file.isNull()) {
this.push(file);
return callback();
}

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);
};
52 changes: 40 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "gulp-unzip",
"version": "1.0.0",
"version": "1.0.1",
"description": "gulp plugin for unzip",
"main": "index.js",
"repository": {
"type": "git",
"url": "https://github.com/inuscript/gulp-unzip.git"
"url": "https://github.com/terrierscript/gulp-unzip.git"
},
"scripts": {
"test": "mocha"
Expand All @@ -16,19 +16,47 @@
"zip",
"package"
],
"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"
}
}
Loading

0 comments on commit 53a84d6

Please sign in to comment.