{"name":"tar-fs","version":"3.0.8","description":"filesystem bindings for tar-stream","dependencies":{"pump":"^3.0.0","tar-stream":"^3.1.5"},"optionalDependencies":{"bare-fs":"^4.0.1","bare-path":"^3.0.0"},"imports":{"fs":{"bare":"bare-fs","default":"fs"},"path":{"bare":"bare-path","default":"path"}},"standard":{"ignore":["test/fixtures/**"]},"keywords":["tar","fs","file","tarball","directory","stream"],"devDependencies":{"brittle":"^3.1.3","rimraf":"^2.6.3","standard":"^17.0.1"},"scripts":{"test":"standard && brittle 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"},"_id":"tar-fs@3.0.8","gitHead":"e4a7a401e80267247b8e9e39d8e5ba82c4fe2f7b","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-ZoROL70jptorGAlgAYiLoBLItEKw/fUxg9BSYK/dF/GAGYFJOJJJMvjPAKDJraCXFwadD456FCuvLWgfhMsPwg==","shasum":"8f62012537d5ff89252d01e48690dc4ebed33ab7","tarball":"http://registry-npm.ywwl.com/tar-fs/download/tar-fs-3.0.8.tgz","fileCount":4,"unpackedSize":17112,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAwDKxFnj0snsEdqjZcRCJBKo8aRv7V7QusWDoT+c1DjAiAuvIzq0s9XauxdnDHGe0KV52sGDqZmLF/rKu6JEHlmxA=="}],"size":5555,"noattachment":false,"key":"/tar-fs/-/tar-fs-3.0.8.tgz"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/tar-fs_3.0.8_1736885148453_0.8714757273823386"},"_hasShrinkwrap":false,"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":1736885148631,"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"},{"name":"maxogden","email":"max@maxogden.com"}],"_cnpm_publish_time":1736885148631,"dist-tags":{"latest":"3.1.4","tmp":"2.1.6"}}