{"name":"tar-fs","version":"3.1.2","keywords":["tar","fs","file","tarball","directory","stream"],"author":{"name":"Mathias Buus"},"license":"MIT","_id":"tar-fs@3.1.2","maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"maxogden","email":"max@maxogden.com"}],"homepage":"https://github.com/mafintosh/tar-fs","bugs":{"url":"https://github.com/mafintosh/tar-fs/issues"},"dist":{"shasum":"114b012f54796f31e62f3e57792820a80b83ae6e","tarball":"http://registry-npm.ywwl.com/tar-fs/download/tar-fs-3.1.2.tgz","fileCount":4,"integrity":"sha512-QGxxTxxyleAdyM3kpFs14ymbYmNFrfY+pHj7Z8FgtbZ7w2//VAgLMac7sT6nRpIHjppXO2AwwEOg0bPFVRcmXw==","signatures":[{"sig":"MEUCIHRRGlLFTwTSp9gG9SjzsfkBJ7voqGvclDVkbk0aFBYLAiEAqb9g1g+0d4yr80x29QBX3vVs7JS3qjJ4lHk1U8bR3Bc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":18167,"size":5734,"noattachment":false,"key":"/tar-fs/-/tar-fs-3.1.2.tgz"},"main":"index.js","gitHead":"522415fc22e07fe29632ad522a9ba70357a10ea5","imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"scripts":{"test":"standard && brittle test/index.js"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"standard":{"ignore":["test/fixtures/**"]},"repository":{"url":"git+https://github.com/mafintosh/tar-fs.git","type":"git"},"_npmVersion":"11.6.2","description":"filesystem bindings for tar-stream","directories":{"test":"test"},"_nodeVersion":"24.13.0","dependencies":{"pump":"^3.0.0","tar-stream":"^3.1.5"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^2.6.3","brittle":"^3.1.3","standard":"^17.0.1"},"optionalDependencies":{"bare-fs":"^4.0.1","bare-path":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/tar-fs_3.1.2_1772664950108_0.7399949612036123","host":"s3://npm-registry-packages-npm-production"},"readme":"# tar-fs\n\nFilesystem bindings for [tar-stream](https://github.com/mafintosh/tar-stream).\n\n```\nnpm install tar-fs\n```\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\nconst tar = require('tar-fs')\nconst 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`\nis also an alias for `filter`. Additionally you get `header` if you use ignore while extracting.\nThat way you could also filter by metadata.\n\n``` js\nconst pack = tar.pack('./my-directory', {\n  ignore (name) {\n    return path.extname(name) === '.bin' // ignore .bin files when packing\n  }\n})\n\nconst extract = tar.extract('./my-other-directory', {\n  ignore (name) {\n    return path.extname(name) === '.bin' // ignore .bin files inside the tarball when extracing\n  }\n})\n\nconst extractFilesDirs = tar.extract('./my-other-other-directory', {\n  ignore (_, header) {\n    // pass files & directories, ignore e.g. symlinks\n    return header.type !== 'file' && header.type !== 'directory'\n  }\n})\n```\n\nYou can also specify which entries to pack using the `entries` option\n\n```js\nconst 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\nconst pack = tar.pack('./my-directory', {\n  map (header) {\n    header.name = 'prefixed/'+header.name\n    return header\n  }\n})\n\nconst extract = tar.extract('./my-directory', {\n  map (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\nconst pack = tar.pack('./my-directory', {\n  mapStream (fileStream, header) {\n    // NOTE: the returned stream HAS to have the same length as the input stream.\n    // If not make sure to update the size in the header passed in here.\n    if (path.extname(header.name) === '.js') {\n      return fileStream.pipe(someTransform)\n    }\n    return fileStream\n  }\n})\n\nconst extract = tar.extract('./my-directory', {\n  mapStream (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\nconst extract = tar.extract('./my-directory', {\n  dmode: parseInt(555, 8), // all dirs should be readable\n  fmode: parseInt(444, 8) // all files should be readable\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\nAlternatively you can set `options.readable` and/or `options.writable` to set the dmode and fmode to readable/writable.\n\n``` js\nvar extract = tar.extract('./my-directory', {\n  readable: true, // all dirs and files should be readable\n  writable: true, // all dirs and files should be writable\n})\n```\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## Interaction with [`tar-stream`](https://github.com/mafintosh/tar-stream)\n\nUse `finalize: false` and the `finish` hook to\nleave the pack stream open for further entries (see\n[`tar-stream#pack`](https://github.com/mafintosh/tar-stream#packing)),\nand use `pack` to pass an existing pack stream.\n\n``` js\nconst mypack = tar.pack('./my-directory', {\n  finalize: false,\n  finish (sameAsMypack) {\n    mypack.entry({name: 'generated-file.txt'}, \"hello\")\n    tar.pack('./other-directory', {\n      pack: sameAsMypack\n    })\n  }\n})\n```\n\n## License\n\nMIT\n","publish_time":1772664950260,"_cnpm_publish_time":1772664950260,"dist-tags":{"latest":"3.1.4","tmp":"2.1.6"}}