{"name":"tar-fs","version":"2.1.4","keywords":["tar","fs","file","tarball","directory","stream"],"author":{"name":"Mathias Buus"},"license":"MIT","_id":"tar-fs@2.1.4","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":"800824dbf4ef06ded9afea4acafe71c67c76b930","tarball":"http://registry-npm.ywwl.com/tar-fs/download/tar-fs-2.1.4.tgz","fileCount":16,"integrity":"sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==","signatures":[{"sig":"MEYCIQDdkJnyzDUqTOuT6iN9TpAzknZoZiyblvYy3zVMyBfqhAIhAPDXIoG0d9BqR7vpzQqe1JwHuKI5U/e+/WfHSN6j1mn5","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":28466,"size":7490,"noattachment":false,"key":"/tar-fs/-/tar-fs-2.1.4.tgz"},"main":"index.js","gitHead":"f421a235565b6a6d305bdf87e999ebdfae9dd1cc","scripts":{"test":"standard && tape test/index.js"},"_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"repository":{"url":"git+https://github.com/mafintosh/tar-fs.git","type":"git"},"_npmVersion":"10.9.2","description":"filesystem bindings for tar-stream","directories":{"test":"test"},"_nodeVersion":"22.16.0","dependencies":{"pump":"^3.0.0","chownr":"^1.1.1","tar-stream":"^2.1.4","mkdirp-classic":"^0.5.2"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tape":"^4.9.2","rimraf":"^2.6.3","standard":"^13.0.1"},"_npmOperationalInternal":{"tmp":"tmp/tar-fs_2.1.4_1758035108142_0.4021671052084954","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":1758035108323,"_cnpm_publish_time":1758035108323,"dist-tags":{"latest":"3.1.4","tmp":"2.1.6"}}