UNPKG

bower

Version:

The browser package manager

49 lines (48 loc) 4.69 kB
{ "name": "tar-fs", "version": "1.8.1", "description": "filesystem bindings for tar-stream", "dependencies": { "mkdirp": "^0.5.0", "pump": "^1.0.0", "tar-stream": "^1.1.2" }, "keywords": [ "tar", "fs", "file", "tarball", "directory", "stream" ], "devDependencies": { "rimraf": "^2.2.8", "standard": "^4.5.4", "tape": "^3.0.0" }, "scripts": { "test": "standard && 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", "repository": { "type": "git", "url": "git+https://github.com/mafintosh/tar-fs.git" }, "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\nIt doesn't gunzip for you, so if you want to extract a `.tar.gz` with this you'll need to use something like [gunzip-maybe](https://github.com/mafintosh/gunzip-maybe) in addition to this.\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. `ignore` is also an alias for `filter`.\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\nYou can also specify which entries to pack using the `entries` option\n\n```js\nvar pack = tar.pack('./my-directory', {\n entries: ['file1', 'subdir/file2'] // only the specific entries will be packed\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.extract('./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, header) {\n if (path.extname(header.name) === '.js') {\n return fileStream.pipe(someTransform)\n }\n return fileStream;\n }\n})\n\nvar extract = tar.extract('./my-directory', {\n mapStream: function(fileStream, header) {\n if (path.extname(header.name) === '.js') {\n return fileStream.pipe(someTransform)\n }\n return fileStream;\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\nSet `options.strict` to `false` if you want to ignore errors due to unsupported entry types (like device files)\n\nTo dereference symlinks (pack the contents of the symlink instead of the link itself) set `options.dereference` to `true`.\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@1.8.1", "_shasum": "3ee6cfa351633775eaa75e3af6ec307e9eaa403c", "_resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-1.8.1.tgz", "_from": "tar-fs@>=1.4.1 <2.0.0" }