{ "name": "tar-fs", "version": "0.5.2", "description": "filesystem bindings for tar-stream", "repository": { "type": "git", "url": "git://github.com:mafintosh/tar-fs.git" }, "dependencies": { "mkdirp": "^0.5.0", "pump": "^0.3.5", "tar-stream": "^0.4.6" }, "keywords": [ "tar", "fs", "file", "tarball", "directory", "stream" ], "devDependencies": { "rimraf": "^2.2.8", "tape": "^3.0.0" }, "scripts": { "test": "tape test/index.js" }, "bugs": { "url": "https://github.com/mafintosh/tar-fs/issues" }, "homepage": "https://github.com/mafintosh/tar-fs", "main": "index.js", "directories": { "test": "test" }, "author": { "name": "Mathias Buus" }, "license": "MIT", "readme": "# tar-fs\n\nfilesystem bindings for [tar-stream](https://github.com/mafintosh/tar-stream).\n\n```\nnpm install tar-fs\n```\n\n[![build status](https://secure.travis-ci.org/mafintosh/tar-fs.png)](http://travis-ci.org/mafintosh/tar-fs)\n\n## Usage\n\ntar-fs allows you to pack directories into tarballs and extract tarballs into directories.\n\n``` js\nvar tar = require('tar-fs')\nvar fs = require('fs')\n\n// packing a directory\ntar.pack('./my-directory').pipe(fs.createWriteStream('my-tarball.tar'))\n\n// extracting a directory\nfs.createReadStream('my-other-tarball.tar').pipe(tar.extract('./my-other-directory'))\n```\n\nTo ignore various files when packing or extracting add a ignore function to the options\n\n``` js\nvar pack = tar.pack('./my-directory', {\n ignore: function(name) {\n return path.extname(name) === '.bin' // ignore .bin files when packing\n }\n})\n\nvar extract = tar.extract('./my-other-directory', {\n ignore: function(name) {\n return path.extname(name) === '.bin' // ignore .bin files inside the tarball when extracing\n }\n})\n```\n\nIf you want to modify the headers when packing/extracting add a map function to the options\n\n``` js\nvar pack = tar.pack('./my-directory', {\n map: function(header) {\n header.name = 'prefixed/'+header.name\n return header\n }\n})\n\nvar extract = tar.pack('./my-directory', {\n map: function(header) {\n header.name = 'another-prefix/'+header.name\n return header\n }\n})\n```\n\nSimilarly you can use `mapStream` incase you wanna modify the input/output file streams\n\n``` js\nvar pack = tar.pack('./my-directory', {\n mapStream: function(fileStream) {\n return fileStream.pipe(someTransform)\n }\n})\n\nvar extract = tar.extract('./my-directory', {\n mapStream: function(fileStream) {\n return fileStream.pipe(someTransform)\n }\n})\n```\n\nSet `options.fmode` and `options.dmode` to ensure that files/directories extracted have the corresponding modes\n\n``` js\nvar extract = tar.extract('./my-directory', {\n dmode: 0555, // all dirs and files should be readable\n fmode: 0444\n})\n```\n\nIt can be useful to use `dmode` and `fmode` if you are packing/unpacking tarballs between *nix/windows to ensure that all files/directories unpacked are readable.\n\n## Copy a directory\n\nCopying a directory with permissions and mtime intact is as simple as\n\n``` js\ntar.pack('source-directory').pipe(tar.extract('dest-directory'))\n```\n\n## Performance\n\nPacking and extracting a 6.1 GB with 2496 directories and 2398 files yields the following results on my Macbook Air.\n[See the benchmark here](https://gist.github.com/mafintosh/8102201)\n\n* tar-fs: 34.261 ms\n* [node-tar](https://github.com/isaacs/node-tar): 366.123 ms (or 10x slower)\n\n## License\n\nMIT\n", "readmeFilename": "README.md", "_id": "tar-fs@0.5.2", "_shasum": "0f59424be7eeee45232316e302f66d3f6ea6db3e", "_from": "tar-fs@0.5.2", "_resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-0.5.2.tgz" }