Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-08-28 03:16:21 +0300
committerForrest L Norvell <forrest@npmjs.com>2015-08-28 03:16:21 +0300
commit19de358254c4de264b263f75b4f6d193571de676 (patch)
tree75453aea605fd3ecf4a445b030edc42e0de0d951 /node_modules/tar
parenteb660309a4c0c88d5caeffd02b41dfdd7c0ced20 (diff)
tar@2.2.0
Add `discard` method to ditch unwanted tar entries.
Diffstat (limited to 'node_modules/tar')
-rw-r--r--node_modules/tar/lib/entry.js7
-rw-r--r--node_modules/tar/lib/parse.js6
-rw-r--r--node_modules/tar/package.json45
-rw-r--r--node_modules/tar/test/parse-discard.js29
4 files changed, 66 insertions, 21 deletions
diff --git a/node_modules/tar/lib/entry.js b/node_modules/tar/lib/entry.js
index 4af5c4108..591202bd3 100644
--- a/node_modules/tar/lib/entry.js
+++ b/node_modules/tar/lib/entry.js
@@ -24,6 +24,7 @@ function Entry (header, extended, global) {
this._ending = false
this._ended = false
this._remaining = 0
+ this._abort = false
this._queue = []
this._index = 0
this._queueLen = 0
@@ -209,5 +210,11 @@ Entry.prototype._setProps = function () {
this._remaining = props.size
}
+// the parser may not call write if _abort is true.
+// useful for skipping data from some files quickly.
+Entry.prototype.abort = function(){
+ this._abort = true
+}
+
Entry.prototype.warn = fstream.warn
Entry.prototype.error = fstream.error
diff --git a/node_modules/tar/lib/parse.js b/node_modules/tar/lib/parse.js
index 1c53d9d26..600ad782f 100644
--- a/node_modules/tar/lib/parse.js
+++ b/node_modules/tar/lib/parse.js
@@ -102,7 +102,11 @@ Parse.prototype._process = function (c) {
if (this._entry) {
var entry = this._entry
- entry.write(c)
+ if(!entry._abort) entry.write(c)
+ else {
+ entry._remaining -= c.length
+ if(entry._remaining < 0) entry._remaining = 0
+ }
if (entry._remaining === 0) {
entry.end()
this._entry = null
diff --git a/node_modules/tar/package.json b/node_modules/tar/package.json
index 30178a0ba..e082df316 100644
--- a/node_modules/tar/package.json
+++ b/node_modules/tar/package.json
@@ -1,37 +1,37 @@
{
"_args": [
[
- "tar@~2.1.1",
- "/Users/rebecca/code/npm"
+ "tar@~2.2.0",
+ "/Users/ogd/Documents/projects/npm/npm"
]
],
- "_from": "tar@>=2.1.1 <2.2.0",
- "_id": "tar@2.1.1",
+ "_from": "tar@>=2.2.0 <2.3.0",
+ "_id": "tar@2.2.0",
"_inCache": true,
"_location": "/tar",
- "_nodeVersion": "1.8.1",
+ "_nodeVersion": "0.12.4",
"_npmUser": {
- "email": "ogd@aoaioxxysz.net",
- "name": "othiym23"
+ "email": "soldair@gmail.com",
+ "name": "soldair"
},
- "_npmVersion": "2.9.1",
+ "_npmVersion": "2.13.4",
"_phantomChildren": {},
"_requested": {
"name": "tar",
- "raw": "tar@~2.1.1",
- "rawSpec": "~2.1.1",
+ "raw": "tar@~2.2.0",
+ "rawSpec": "~2.2.0",
"scope": null,
- "spec": ">=2.1.1 <2.2.0",
+ "spec": ">=2.2.0 <2.3.0",
"type": "range"
},
"_requiredBy": [
"/"
],
- "_resolved": "https://registry.npmjs.org/tar/-/tar-2.1.1.tgz",
- "_shasum": "ac0649e135fa4546e430c7698514e1da2e8a7cc4",
+ "_resolved": "https://registry.npmjs.org/tar/-/tar-2.2.0.tgz",
+ "_shasum": "527c595940b9673f386c7237759982ab2f274d08",
"_shrinkwrap": null,
- "_spec": "tar@~2.1.1",
- "_where": "/Users/rebecca/code/npm",
+ "_spec": "tar@~2.2.0",
+ "_where": "/Users/ogd/Documents/projects/npm/npm",
"author": {
"email": "i@izs.me",
"name": "Isaac Z. Schlueter",
@@ -54,21 +54,26 @@
},
"directories": {},
"dist": {
- "shasum": "ac0649e135fa4546e430c7698514e1da2e8a7cc4",
- "tarball": "http://registry.npmjs.org/tar/-/tar-2.1.1.tgz"
+ "shasum": "527c595940b9673f386c7237759982ab2f274d08",
+ "tarball": "http://registry.npmjs.org/tar/-/tar-2.2.0.tgz"
},
- "gitHead": "2cbe6c805fc5d87ce099183ed13c43faba962224",
+ "gitHead": "3cab63959c51451a84cc8d1f8ef02d45b8b4f836",
"homepage": "https://github.com/isaacs/node-tar#readme",
+ "installable": true,
"license": "ISC",
"main": "tar.js",
"maintainers": [
{
"name": "isaacs",
- "email": "i@izs.me"
+ "email": "isaacs@npmjs.com"
},
{
"name": "othiym23",
"email": "ogd@aoaioxxysz.net"
+ },
+ {
+ "name": "soldair",
+ "email": "soldair@gmail.com"
}
],
"name": "tar",
@@ -80,5 +85,5 @@
"scripts": {
"test": "tap test/*.js"
},
- "version": "2.1.1"
+ "version": "2.2.0"
}
diff --git a/node_modules/tar/test/parse-discard.js b/node_modules/tar/test/parse-discard.js
new file mode 100644
index 000000000..da01a65cc
--- /dev/null
+++ b/node_modules/tar/test/parse-discard.js
@@ -0,0 +1,29 @@
+var tap = require("tap")
+ , tar = require("../tar.js")
+ , fs = require("fs")
+ , path = require("path")
+ , file = path.resolve(__dirname, "fixtures/c.tar")
+
+tap.test("parser test", function (t) {
+ var parser = tar.Parse()
+ var total = 0
+ var dataTotal = 0
+
+ parser.on("end", function () {
+
+ t.equals(total-513,dataTotal,'should have discarded only c.txt')
+
+ t.end()
+ })
+
+ fs.createReadStream(file)
+ .pipe(parser)
+ .on('entry',function(entry){
+ if(entry.path === 'c.txt') entry.abort()
+
+ total += entry.size;
+ entry.on('data',function(data){
+ dataTotal += data.length
+ })
+ })
+})