decompress-tarbz2
Advanced tools
Comparing version 1.0.2 to 2.0.0
27
index.js
'use strict'; | ||
var bz2 = require('seek-bzip'); | ||
var File = require('vinyl'); | ||
var isBzip2 = require('is-bzip2'); | ||
@@ -8,2 +9,3 @@ var sbuff = require('simple-bufferstream'); | ||
var tar = require('tar'); | ||
var through = require('through2'); | ||
@@ -21,7 +23,17 @@ /** | ||
return function (file, decompress, cb) { | ||
var files = []; | ||
return through.obj(function (file, enc, cb) { | ||
var self = this; | ||
if (file.isNull()) { | ||
cb(null, file); | ||
return; | ||
} | ||
if (file.isStream()) { | ||
cb(new Error('Streaming is not supported')); | ||
return; | ||
} | ||
if (!isBzip2(file.contents)) { | ||
cb(); | ||
cb(null, file); | ||
return; | ||
@@ -49,4 +61,6 @@ } | ||
file.on('end', function () { | ||
chunk = Buffer.concat(chunk, len); | ||
files.push({ contents: chunk, path: stripDirs(file.path, opts.strip) }); | ||
self.push(new File({ | ||
contents: Buffer.concat(chunk, len), | ||
path: stripDirs(file.path, opts.strip) | ||
})); | ||
}); | ||
@@ -57,6 +71,5 @@ } | ||
.on('end', function () { | ||
decompress.files = files; | ||
cb(); | ||
}); | ||
}; | ||
}); | ||
}; |
{ | ||
"name": "decompress-tarbz2", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "decompress tar.bz2 plugin", | ||
@@ -35,9 +35,11 @@ "license": "MIT", | ||
"strip-dirs": "^0.1.1", | ||
"tar": "^1.0.0" | ||
"tar": "^1.0.0", | ||
"through2": "^0.6.1", | ||
"vinyl": "^0.4.3" | ||
}, | ||
"devDependencies": { | ||
"ava": "0.0.4", | ||
"decompress": "^1.0.0", | ||
"rimraf": "^2.2.8" | ||
"is-jpg": "^1.0.0", | ||
"vinyl-file": "^1.1.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
# decompress-tarbz2 [![Build Status](https://travis-ci.org/kevva/decompress-tarbz2.svg?branch=master)](https://travis-ci.org/kevva/decompress-tarbz2) | ||
# decompress-tarbz2 [![Build Status](http://img.shields.io/travis/kevva/decompress-tarbz2.svg?style=flat)](https://travis-ci.org/kevva/decompress-tarbz2) | ||
@@ -19,8 +19,27 @@ > tar.bz2 decompress plugin | ||
.src('foo.tar.bz2') | ||
.dest('destFolder') | ||
.dest('dest') | ||
.use(tarbz2({ strip: 1 })); | ||
decompress.decompress(); | ||
decompress.run(function (err, files) { | ||
if (err) { | ||
throw err; | ||
} | ||
console.log('Files extracted successfully!'); | ||
}); | ||
``` | ||
You can also use this plugin with [gulp](http://gulpjs.com): | ||
```js | ||
var gulp = require('gulp'); | ||
var tarbz2 = require('decompress-tarbz2'); | ||
gulp.task('default', function () { | ||
return gulp.src('foo.tar.bz2') | ||
.pipe(tarbz2({ strip: 1 })) | ||
.pipe(gulp.dest('dest')); | ||
}); | ||
``` | ||
## Options | ||
@@ -27,0 +46,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3654
58
56
7
+ Addedthrough2@^0.6.1
+ Addedvinyl@^0.4.3
+ Addedclone@0.2.0(transitive)
+ Addedclone-stats@0.0.1(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedisarray@0.0.1(transitive)
+ Addedreadable-stream@1.0.34(transitive)
+ Addedstring_decoder@0.10.31(transitive)
+ Addedthrough2@0.6.5(transitive)
+ Addedvinyl@0.4.6(transitive)
+ Addedxtend@4.0.2(transitive)