tar@1.0.1

This commit is contained in:
isaacs
2014-08-20 11:57:26 -07:00
parent 70fd11d27c
commit a8ed12b939
6 changed files with 216 additions and 14 deletions

15
node_modules/tar/package.json generated vendored
View File

@@ -6,7 +6,7 @@
},
"name": "tar",
"description": "tar for node",
"version": "1.0.0",
"version": "1.0.1",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-tar.git"
@@ -17,22 +17,23 @@
},
"dependencies": {
"block-stream": "*",
"fstream": "^1.0.0",
"fstream": "^1.0.2",
"inherits": "2"
},
"devDependencies": {
"tap": "0.x",
"rimraf": "1.x"
"graceful-fs": "^3.0.2",
"rimraf": "1.x",
"tap": "0.x"
},
"license": "BSD",
"readme": "# node-tar\n\nTar for Node.js.\n\n[![NPM](https://nodei.co/npm/tar.png)](https://nodei.co/npm/tar/)\n\n## API\n\nSee `examples/` for usage examples.\n\n### var tar = require('tar')\n\nReturns an object with `.Pack`, `.Extract` and `.Parse` methods.\n\n### tar.Pack([properties])\n\nReturns a through stream. Use\n[fstream](https://npmjs.org/package/fstream) to write files into the\npack stream and you will receive tar archive data from the pack\nstream.\n\nThis only works with directories, it does not work with individual files.\n\nThe optional `properties` object are used to set properties in the tar\n'Global Extended Header'.\n\n### tar.Extract([options])\n\nReturns a through stream. Write tar data to the stream and the files\nin the tarball will be extracted onto the filesystem.\n\n`options` can be:\n\n```js\n{\n path: '/path/to/extract/tar/into',\n strip: 0, // how many path segments to strip from the root when extracting\n}\n```\n\n`options` also get passed to the `fstream.Writer` instance that `tar`\nuses internally.\n\n### tar.Parse()\n\nReturns a writable stream. Write tar data to it and it will emit\n`entry` events for each entry parsed from the tarball. This is used by\n`tar.Extract`.\n",
"readmeFilename": "README.md",
"gitHead": "49979621a55c73c3f668d8e01830eba1ea9df862",
"gitHead": "476bf6f5882b9c33d1cbf66f175d0f25e3981044",
"bugs": {
"url": "https://github.com/isaacs/node-tar/issues"
},
"homepage": "https://github.com/isaacs/node-tar",
"_id": "tar@1.0.0",
"_shasum": "36636d76e8ae12b4bc11a940ac606b5ca8a5fe1f",
"_id": "tar@1.0.1",
"_shasum": "6075b5a1f236defe0c7e3756d3d9b3ebdad0f19a",
"_from": "tar@latest"
}

132
node_modules/tar/test/extract-move.js generated vendored Normal file
View File

@@ -0,0 +1,132 @@
// Set the umask, so that it works the same everywhere.
process.umask(parseInt('22', 8))
var tap = require("tap")
, tar = require("../tar.js")
, fs = require("fs")
, gfs = require("graceful-fs")
, path = require("path")
, file = path.resolve(__dirname, "fixtures/dir.tar")
, target = path.resolve(__dirname, "tmp/extract-test")
, index = 0
, fstream = require("fstream")
, rimraf = require("rimraf")
, mkdirp = require("mkdirp")
, ee = 0
, expectEntries = [
{
"path" : "dir/",
"mode" : "750",
"type" : "5",
"depth" : undefined,
"size" : 0,
"linkpath" : "",
"nlink" : undefined,
"dev" : undefined,
"ino" : undefined
},
{
"path" : "dir/sub/",
"mode" : "750",
"type" : "5",
"depth" : undefined,
"size" : 0,
"linkpath" : "",
"nlink" : undefined,
"dev" : undefined,
"ino" : undefined
} ]
function slow (fs, method, t1, t2) {
var orig = fs[method]
if (!orig) return null
fs[method] = function () {
var args = [].slice.call(arguments)
console.error("slow", method, args[0])
var cb = args.pop()
setTimeout(function () {
orig.apply(fs, args.concat(function(er, data) {
setTimeout(function() {
cb(er, data)
}, t2)
}))
}, t1)
}
}
// Make sure we get the graceful-fs that fstream is using.
var gfs2
try {
gfs2 = require("fstream/node_modules/graceful-fs")
} catch (er) {}
var slowMethods = ["chown", "chmod", "utimes", "lutimes"]
slowMethods.forEach(function (method) {
var t1 = 500
var t2 = 0
slow(fs, method, t1, t2)
slow(gfs, method, t1, t2)
if (gfs2) {
slow(gfs2, method, t1, t2)
}
})
// The extract class basically just pipes the input
// to a Reader, and then to a fstream.DirWriter
// So, this is as much a test of fstream.Reader and fstream.Writer
// as it is of tar.Extract, but it sort of makes sense.
tap.test("preclean", function (t) {
rimraf.sync(target)
/mkdirp.sync(target)
t.pass("cleaned!")
t.end()
})
tap.test("extract test", function (t) {
var extract = tar.Extract(target)
var inp = fs.createReadStream(file)
// give it a weird buffer size to try to break in odd places
inp.bufferSize = 1234
inp.pipe(extract)
extract.on("end", function () {
rimraf.sync(target)
t.equal(ee, expectEntries.length, "should see "+ee+" entries")
// should get no more entries after end
extract.removeAllListeners("entry")
extract.on("entry", function (e) {
t.fail("Should not get entries after end!")
})
t.end()
})
extract.on("entry", function (entry) {
var found =
{ path: entry.path
, mode: entry.props.mode.toString(8)
, type: entry.props.type
, depth: entry.props.depth
, size: entry.props.size
, linkpath: entry.props.linkpath
, nlink: entry.props.nlink
, dev: entry.props.dev
, ino: entry.props.ino
}
var wanted = expectEntries[ee ++]
t.equivalent(found, wanted, "tar entry " + ee + " " + wanted.path)
})
})

BIN
node_modules/tar/test/fixtures.tgz generated vendored

Binary file not shown.

View File

@@ -149,6 +149,38 @@ var tap = require("tap")
devmin: 0,
fill: '' } ]
, [ 'entry',
{ path: 'fixtures/dir/',
mode: 488,
uid: uid,
gid: gid,
size: 0,
type: '5',
linkpath: '',
ustar: 'ustar\u0000',
ustarver: '00',
uname: '',
gname: '',
devmaj: 0,
devmin: 0,
fill: '' } ]
, [ 'entry',
{ path: 'fixtures/dir/sub/',
mode: 488,
uid: uid,
gid: gid,
size: 0,
type: '5',
linkpath: '',
ustar: 'ustar\u0000',
ustarver: '00',
uname: '',
gname: '',
devmaj: 0,
devmin: 0,
fill: '' } ]
, [ 'entry',
{ path: 'fixtures/foo.js',
mode: 420,
@@ -823,7 +855,7 @@ function runTest (t, doGH) {
t.equal(ev, wanted[0], "event type should be "+wanted[0])
if (ev !== wanted[0] || e.path !== wanted[1].path) {
console.error(wanted)
console.error("wanted", wanted)
console.error([ev, e.props])
e.on("end", function () {
console.error(e.fields)

47
node_modules/tar/test/pack.js generated vendored
View File

@@ -177,6 +177,39 @@ var tap = require("tap")
devmin: 0,
fill: '' } ]
, [ 'entry',
{ path: 'fixtures/dir/',
mode: 488,
uid: uid,
gid: gid,
size: 0,
type: '5',
linkpath: '',
ustar: 'ustar\u0000',
ustarver: '00',
uname: '',
gname: '',
devmaj: 0,
devmin: 0,
fill: '' } ]
, [ 'entry',
{ path: 'fixtures/dir/sub/',
mode: 488,
uid: uid,
gid: gid,
size: 0,
type: '5',
linkpath: '',
ustar: 'ustar\u0000',
ustarver: '00',
uname: '',
gname: '',
devmaj: 0,
devmin: 0,
fill: '' } ]
, [ 'entry',
{ path: 'fixtures/foo.js',
mode: 420,
@@ -868,11 +901,15 @@ function runTest (t, doGH) {
}
t.equal(ev, wanted[0], "event type should be "+wanted[0])
// if (ev !== wanted[0] || e.path !== wanted[1].path) {
// console.error(wanted)
// console.error([ev, e.props])
// throw "break"
// }
if (ev !== wanted[0] || e.path !== wanted[1].path) {
console.error("wanted", wanted)
console.error([ev, e.props])
e.on("end", function () {
console.error(e.fields)
throw "break"
})
}
t.has(e.props, wanted[1], "properties "+wanted[1].path)
if (wanted[2]) {

View File

@@ -79,7 +79,7 @@
"sha": "~1.2.1",
"slide": "~1.1.5",
"sorted-object": "~1.0.0",
"tar": "~1.0.0",
"tar": "~1.0.1",
"text-table": "~0.2.0",
"uid-number": "0.0.5",
"which": "1"