mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
1 line
49 KiB
JSON
1 line
49 KiB
JSON
{"name":"tar","description":"tar for node","dist-tags":{"latest":"6.2.1"},"versions":{"6.2.1":{"name":"tar","version":"6.2.1","author":{"name":"GitHub Inc."},"license":"ISC","_id":"tar@6.2.1","bugs":{"url":"https://github.com/isaacs/node-tar/issues"},"tap":{"nyc-arg":["--exclude","tap-snapshots/**"],"timeout":0,"coverage-map":"map.js"},"dist":{"shasum":"717549c541bc3c2af15751bea94b1dd068d4b03a","tarball":"http://localhost:4260/tar/tar-6.2.1.tgz","fileCount":29,"integrity":"sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==","signatures":[{"sig":"MEQCICiN57b6g7ZWCQN3sRJ+KpQedOYvNEmp0rJiwyGiT6ilAiA92/r4ohXAxTc9ATTxiPbhsnqxFx5d2WFp4qzPVMI+cA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":166613},"engines":{"node":">=10"},"gitHead":"c65f76d89a69a4c0d2a1e3ab97c289ce965f6476","scripts":{"snap":"tap","test":"tap","genparse":"node scripts/generate-parse-fixtures.js"},"repository":{"url":"git+https://github.com/isaacs/node-tar.git","type":"git"},"_npmVersion":"10.5.0","description":"tar for node","directories":{},"templateOSS":{"content":"scripts/template-oss","engines":">=10","version":"4.11.0","distPaths":["index.js"],"allowPaths":["/index.js"],"ciVersions":["10.x","12.x","14.x","16.x","18.x"],"//@npmcli/template-oss":"This file is partially managed by @npmcli/template-oss. Edits may be overwritten."},"_nodeVersion":"20.11.0","dependencies":{"chownr":"^2.0.0","mkdirp":"^1.0.3","yallist":"^4.0.0","minipass":"^5.0.0","minizlib":"^2.1.1","fs-minipass":"^2.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tap":"^16.0.1","nock":"^13.2.9","chmodr":"^1.2.0","rimraf":"^3.0.2","mutate-fs":"^2.1.1","end-of-stream":"^1.4.3","events-to-array":"^2.0.3","@npmcli/template-oss":"4.11.0","@npmcli/eslint-config":"^4.0.0"}}},"author":{"name":"GitHub Inc."},"repository":{"type":"git","url":"git+https://github.com/isaacs/node-tar.git"},"license":"ISC","homepage":"https://github.com/isaacs/node-tar#readme","bugs":{"url":"https://github.com/isaacs/node-tar/issues"},"readme":"# node-tar\n\nFast and full-featured Tar for Node.js\n\nThe API is designed to mimic the behavior of `tar(1)` on unix systems.\nIf you are familiar with how tar works, most of this will hopefully be\nstraightforward for you. If not, then hopefully this module can teach\nyou useful unix skills that may come in handy someday :)\n\n## Background\n\nA \"tar file\" or \"tarball\" is an archive of file system entries\n(directories, files, links, etc.) The name comes from \"tape archive\".\nIf you run `man tar` on almost any Unix command line, you'll learn\nquite a bit about what it can do, and its history.\n\nTar has 5 main top-level commands:\n\n- `c` Create an archive\n- `r` Replace entries within an archive\n- `u` Update entries within an archive (ie, replace if they're newer)\n- `t` List out the contents of an archive\n- `x` Extract an archive to disk\n\nThe other flags and options modify how this top level function works.\n\n## High-Level API\n\nThese 5 functions are the high-level API. All of them have a\nsingle-character name (for unix nerds familiar with `tar(1)`) as well\nas a long name (for everyone else).\n\nAll the high-level functions take the following arguments, all three\nof which are optional and may be omitted.\n\n1. `options` - An optional object specifying various options\n2. `paths` - An array of paths to add or extract\n3. `callback` - Called when the command is completed, if async. (If\n sync or no file specified, providing a callback throws a\n `TypeError`.)\n\nIf the command is sync (ie, if `options.sync=true`), then the\ncallback is not allowed, since the action will be completed immediately.\n\nIf a `file` argument is specified, and the command is async, then a\n`Promise` is returned. In this case, if async, a callback may be\nprovided which is called when the command is completed.\n\nIf a `file` option is not specified, then a stream is returned. For\n`create`, this is a readable stream of the generated archive. For\n`list` and `extract` this is a writable stream that an archive should\nbe written into. If a file is not specified, then a callback is not\nallowed, because you're already getting a stream to work with.\n\n`replace` and `update` only work on existing archives, and so require\na `file` argument.\n\nSync commands without a file argument return a stream that acts on its\ninput immediately in the same tick. For readable streams, this means\nthat all of the data is immediately available by calling\n`stream.read()`. For writable streams, it will be acted upon as soon\nas it is provided, but this can be at any time.\n\n### Warnings and Errors\n\nTar emits warnings and errors for recoverable and unrecoverable situations,\nrespectively. In many cases, a warning only affects a single entry in an\narchive, or is simply informing you that it's modifying an entry to comply\nwith the settings provided.\n\nUnrecoverable warnings will always raise an error (ie, emit `'error'` on\nstreaming actions, throw for non-streaming sync actions, reject the\nreturned Promise for non-streaming async operations, or call a provided\ncallback with an `Error` as the first argument). Recoverable errors will\nraise an error only if `strict: true` is set in the options.\n\nRespond to (recoverable) warnings by listening to the `warn` event.\nHandlers receive 3 arguments:\n\n- `code` String. One of the error codes below. This may not match\n `data.code`, which preserves the original error code from fs and zlib.\n- `message` String. More details about the error.\n- `data` Metadata about the error. An `Error` object for errors raised by\n fs and zlib. All fields are attached to errors raisd by tar. Typically\n contains the following fields, as relevant:\n - `tarCode` The tar error code.\n - `code` Either the tar error code, or the error code set by the\n underlying system.\n - `file` The archive file being read or written.\n - `cwd` Working directory for creation and extraction operations.\n - `entry` The entry object (if it could be created) for `TAR_ENTRY_INFO`,\n `TAR_ENTRY_INVALID`, and `TAR_ENTRY_ERROR` warnings.\n - `header` The header object (if it could be created, and the entry could\n not be created) for `TAR_ENTRY_INFO` and `TAR_ENTRY_INVALID` warnings.\n - `recoverable` Boolean. If `false`, then the warning will emit an\n `error`, even in non-strict mode.\n\n#### Error Codes\n\n- `TAR_ENTRY_INFO` An informative error indicating that an entry is being\n modified, but otherwise processed normally. For example, removing `/` or\n `C:\\` from absolute paths if `preservePaths` is not set.\n\n- `TAR_ENTRY_INVALID` An indication that a given entry is not a valid tar\n archive entry, and will be skipped. This occurs when:\n\n - a checksum fails,\n - a `linkpath` is missing for a link type, or\n - a `linkpath` is provided for a non-link type.\n\n If every entry in a parsed archive raises an `TAR_ENTRY_INVALID` error,\n then the archive is presumed to be unrecoverably broken, and\n `TAR_BAD_ARCHIVE` will be raised.\n\n- `TAR_ENTRY_ERROR` The entry appears to be a valid tar archive entry, but\n encountered an error which prevented it from being unpacked. This occurs\n when:\n\n - an unrecoverable fs error happens during unpacking,\n - an entry is trying to extract into an excessively deep\n location (by default, limited to 1024 subfolders),\n - an entry has `..` in the path and `preservePaths` is not set, or\n - an entry is extracting through a symbolic link, when `preservePaths` is\n not set.\n\n- `TAR_ENTRY_UNSUPPORTED` An indication that a given entry is\n a valid archive entry, but of a type that is unsupported, and so will be\n skipped in archive creation or extracting.\n\n- `TAR_ABORT` When parsing gzipped-encoded archives, the parser will\n abort the parse process raise a warning for any zlib errors encountered.\n Aborts are considered unrecoverable for both parsing and unpacking.\n\n- `TAR_BAD_ARCHIVE` The archive file is totally hosed. This can happen for\n a number of reasons, and always occurs at the end of a parse or extract:\n\n - An entry body was truncated before seeing the full number of bytes.\n - The archive contained only invalid entries, indicating that it is\n likely not an archive, or at least, not an archive this library can\n parse.\n\n `TAR_BAD_ARCHIVE` is considered informative for parse operations, but\n unrecoverable for extraction. Note that, if encountered at the end of an\n extraction, tar WILL still have extracted as much it could from the\n archive, so there may be some garbage files to clean up.\n\nErrors that occur deeper in the system (ie, either the filesystem or zlib)\nwill have their error codes left intact, and a `tarCode` matching one of\nthe above will be added to the warning metadata or the raised error object.\n\nErrors generated by tar will have one of the above codes set as the\n`error.code` field as well, but since errors originating in zlib or fs will\nhave their original codes, it's better to read `error.tarCode` if you wish\nto see how tar is handling the issue.\n\n### Examples\n\nThe API mimics the `tar(1)` command line functionality, with aliases\nfor more human-readable option and function names. The goal is that\nif you know how to use `tar(1)` in Unix, then you know how to use\n`import('tar')` in JavaScript.\n\nTo replicate `tar czf my-tarball.tgz files and folders`, you'd do:\n\n```js\nimport { create } from 'tar'\ncreate(\n {\n gzip: <true|gzip options>,\n file: 'my-tarball.tgz'\n },\n ['some', 'files', 'and', 'folders']\n).then(_ => { .. tarball has been created .. })\n```\n\nTo replicate `tar cz files and folders > my-tarball.tgz`, you'd do:\n\n```js\n// if you're familiar with the tar(1) cli flags, this can be nice\nimport * as tar from 'tar'\ntar.c(\n {\n // 'z' is alias for 'gzip' option\n z: <true|gzip options>\n },\n ['some', 'files', 'and', 'folders']\n).pipe(fs.createWriteStream('my-tarball.tgz'))\n```\n\nTo replicate `tar xf my-tarball.tgz` you'd do:\n\n```js\ntar.x( // or `tar.extract`\n {\n // or `file:`\n f: 'my-tarball.tgz'\n }\n).then(_=> { .. tarball has been dumped in cwd .. })\n```\n\nTo replicate `cat my-tarball.tgz | tar x -C some-dir --strip=1`:\n\n```js\nfs.createReadStream('my-tarball.tgz').pipe(\n tar.x({\n strip: 1,\n C: 'some-dir', // alias for cwd:'some-dir', also ok\n }),\n)\n```\n\nTo replicate `tar tf my-tarball.tgz`, do this:\n\n```js\ntar.t({\n file: 'my-tarball.tgz',\n onReadEntry: entry => { .. do whatever with it .. }\n})\n```\n\nFor example, to just get the list of filenames from an archive:\n\n```js\nconst getEntryFilenames = async tarballFilename => {\n const filenames = []\n await tar.t({\n file: tarballFilename,\n onReadEntry: entry => filenames.push(entry.path),\n })\n return filenames\n}\n```\n\nTo replicate `cat my-tarball.tgz | tar t` do:\n\n```js\nfs.createReadStream('my-tarball.tgz')\n .pipe(tar.t())\n .on('entry', entry => { .. do whatever with it .. })\n```\n\nTo do anything synchronous, add `sync: true` to the options. Note\nthat sync functions don't take a callback and don't return a promise.\nWhen the function returns, it's already done. Sync methods without a\nfile argument return a sync stream, which flushes immediately. But,\nof course, it still won't be done until you `.end()` it.\n\n```js\nconst getEntryFilenamesSync = tarballFilename => {\n const filenames = []\n tar.t({\n file: tarballFilename,\n onReadEntry: entry => filenames.push(entry.path),\n sync: true,\n })\n return filenames\n}\n```\n\nTo filter entries, add `filter: <function>` to the options.\nTar-creating methods call the filter with `filter(path, stat)`.\nTar-reading methods (including extraction) call the filter with\n`filter(path, entry)`. The filter is called in the `this`-context of\nthe `Pack` or `Unpack` stream object.\n\nThe arguments list to `tar t` and `tar x` specify a list of filenames\nto extract or list, so they're equivalent to a filter that tests if\nthe file is in the list.\n\nFor those who _aren't_ fans of tar's single-character command names:\n\n```\ntar.c === tar.create\ntar.r === tar.replace (appends to archive, file is required)\ntar.u === tar.update (appends if newer, file is required)\ntar.x === tar.extract\ntar.t === tar.list\n```\n\nKeep reading for all the command descriptions and options, as well as\nthe low-level API that they are built on.\n\n### tar.c(options, fileList, callback) [alias: tar.create]\n\nCreate a tarball archive.\n\nThe `fileList` is an array of paths to add to the tarball. Adding a\ndirectory also adds its children recursively.\n\nAn entry in `fileList` that starts with an `@` symbol is a tar archive\nwhose entries will be added. To add a file that starts with `@`,\nprepend it with `./`.\n\nThe following options are supported:\n\n- `file` Write the tarball archive to the specified filename. If this\n is specified, then the callback will be fired when the file has been\n written, and a promise will be returned that resolves when the file\n is written. If a filename is not specified, then a Readable Stream\n will be returned which will emit the file data. [Alias: `f`]\n- `sync` Act synchronously. If this is set, then any provided file\n will be fully written after the call to `tar.c`. If this is set,\n and a file is not provided, then the resulting stream will already\n have the data ready to `read` or `emit('data')` as soon as you\n request it.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `cwd` The current working directory for creating the archive.\n Defaults to `process.cwd()`. [Alias: `C`]\n- `prefix` A path portion to prefix onto the entries in the archive.\n- `gzip` Set to any truthy value to create a gzipped archive, or an\n object with settings for `zlib.Gzip()` [Alias: `z`]\n- `filter` A function that gets called with `(path, stat)` for each\n entry being added. Return `true` to add the entry to the archive,\n or `false` to omit it.\n- `portable` Omit metadata that is system-specific: `ctime`, `atime`,\n `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note\n that `mtime` is still included, because this is necessary for other\n time-based operations. Additionally, `mode` is set to a \"reasonable\n default\" for most unix systems, based on a `umask` value of `0o22`.\n- `preservePaths` Allow absolute paths. By default, `/` is stripped\n from absolute paths. [Alias: `P`]\n- `mode` The mode to set on the created file archive\n- `noDirRecurse` Do not recursively archive the contents of\n directories. [Alias: `n`]\n- `follow` Set to true to pack the targets of symbolic links. Without\n this option, symbolic links are archived as such. [Alias: `L`, `h`]\n- `noPax` Suppress pax extended headers. Note that this means that\n long paths and linkpaths will be truncated, and large or negative\n numeric values may be interpreted incorrectly.\n- `noMtime` Set to true to omit writing `mtime` values for entries.\n Note that this prevents using other mtime-based features like\n `tar.update` or the `keepNewer` option with the resulting tar archive.\n [Alias: `m`, `no-mtime`]\n- `mtime` Set to a `Date` object to force a specific `mtime` for\n everything added to the archive. Overridden by `noMtime`.\n- `onWriteEntry` Called with each `WriteEntry` or\n `WriteEntrySync` that is created in the course of writing the\n archive.\n\nThe following options are mostly internal, but can be modified in some\nadvanced use cases, such as re-using caches between runs.\n\n- `linkCache` A Map object containing the device and inode value for\n any file whose nlink is > 1, to identify hard links.\n- `statCache` A Map object that caches calls `lstat`.\n- `readdirCache` A Map object that caches calls to `readdir`.\n- `jobs` A number specifying how many concurrent jobs to run.\n Defaults to 4.\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 16 MB.\n\n### tar.x(options, fileList, callback) [alias: tar.extract]\n\nExtract a tarball archive.\n\nThe `fileList` is an array of paths to extract from the tarball. If\nno paths are provided, then all the entries are extracted.\n\nIf the archive is gzipped, then tar will detect this and unzip it.\n\nNote that all directories that are created will be forced to be\nwritable, readable, and listable by their owner, to avoid cases where\na directory prevents extraction of child entries by virtue of its\nmode.\n\nMost extraction errors will cause a `warn` event to be emitted. If\nthe `cwd` is missing, or not a directory, then the extraction will\nfail completely.\n\nThe following options are supported:\n\n- `cwd` Extract files relative to the specified directory. Defaults\n to `process.cwd()`. If provided, this must exist and must be a\n directory. [Alias: `C`]\n- `file` The archive file to extract. If not specified, then a\n Writable stream is returned where the archive data should be\n written. [Alias: `f`]\n- `sync` Create files and directories synchronously.\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `filter` A function that gets called with `(path, entry)` for each\n entry being unpacked. Return `true` to unpack the entry from the\n archive, or `false` to skip it.\n- `newer` Set to true to keep the existing file on disk if it's newer\n than the file in the archive. [Alias: `keep-newer`,\n `keep-newer-files`]\n- `keep` Do not overwrite existing files. In particular, if a file\n appears more than once in an archive, later copies will not\n overwrite earlier copies. [Alias: `k`, `keep-existing`]\n- `preservePaths` Allow absolute paths, paths containing `..`, and\n extracting through symbolic links. By default, `/` is stripped from\n absolute paths, `..` paths are not extracted, and any file whose\n location would be modified by a symbolic link is not extracted.\n [Alias: `P`]\n- `unlink` Unlink files before creating them. Without this option,\n tar overwrites existing files, which preserves existing hardlinks.\n With this option, existing hardlinks will be broken, as will any\n symlink that would affect the location of an extracted file. [Alias:\n `U`]\n- `strip` Remove the specified number of leading path elements.\n Pathnames with fewer elements will be silently skipped. Note that\n the pathname is edited after applying the filter, but before\n security checks. [Alias: `strip-components`, `stripComponents`]\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `preserveOwner` If true, tar will set the `uid` and `gid` of\n extracted entries to the `uid` and `gid` fields in the archive.\n This defaults to true when run as root, and false otherwise. If\n false, then files and directories will be set with the owner and\n group of the user running the process. This is similar to `-p` in\n `tar(1)`, but ACLs and other system-specific data is never unpacked\n in this implementation, and modes are set by default already.\n [Alias: `p`]\n- `uid` Set to a number to force ownership of all extracted files and\n folders, and all implicitly created directories, to be owned by the\n specified user id, regardless of the `uid` field in the archive.\n Cannot be used along with `preserveOwner`. Requires also setting a\n `gid` option.\n- `gid` Set to a number to force ownership of all extracted files and\n folders, and all implicitly created directories, to be owned by the\n specified group id, regardless of the `gid` field in the archive.\n Cannot be used along with `preserveOwner`. Requires also setting a\n `uid` option.\n- `noMtime` Set to true to omit writing `mtime` value for extracted\n entries. [Alias: `m`, `no-mtime`]\n- `transform` Provide a function that takes an `entry` object, and\n returns a stream, or any falsey value. If a stream is provided,\n then that stream's data will be written instead of the contents of\n the archive entry. If a falsey value is provided, then the entry is\n written to disk as normal. (To exclude items from extraction, use\n the `filter` option described above.)\n- `onReadEntry` A function that gets called with `(entry)` for each entry\n that passes the filter.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `chmod` Set to true to call `fs.chmod()` to ensure that the\n extracted file matches the entry mode. This may necessitate a\n call to the deprecated and thread-unsafe `process.umask()`\n method to determine the default umask value, unless a\n `processUmask` options is also provided. Otherwise tar will\n extract with whatever mode is provided, and let the process\n `umask` apply normally.\n- `processUmask` Set to an explicit numeric value to avoid\n calling `process.umask()` when `chmod: true` is set.\n- `maxDepth` The maximum depth of subfolders to extract into. This\n defaults to 1024. Anything deeper than the limit will raise a\n warning and skip the entry. Set to `Infinity` to remove the\n limitation.\n\nThe following options are mostly internal, but can be modified in some\nadvanced use cases, such as re-using caches between runs.\n\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 16 MB.\n- `umask` Filter the modes of entries like `process.umask()`.\n- `dmode` Default mode for directories\n- `fmode` Default mode for files\n- `dirCache` A Map object of which directories exist.\n- `maxMetaEntrySize` The maximum size of meta entries that is\n supported. Defaults to 1 MB.\n\nNote that using an asynchronous stream type with the `transform`\noption will cause undefined behavior in sync extractions.\n[MiniPass](http://npm.im/minipass)-based streams are designed for this\nuse case.\n\n### tar.t(options, fileList, callback) [alias: tar.list]\n\nList the contents of a tarball archive.\n\nThe `fileList` is an array of paths to list from the tarball. If\nno paths are provided, then all the entries are listed.\n\nIf the archive is gzipped, then tar will detect this and unzip it.\n\nIf the `file` option is _not_ provided, then returns an event emitter that\nemits `entry` events with `tar.ReadEntry` objects. However, they don't\nemit `'data'` or `'end'` events. (If you want to get actual readable\nentries, use the `tar.Parse` class instead.)\n\nIf a `file` option _is_ provided, then the return value will be a promise\nthat resolves when the file has been fully traversed in async mode, or\n`undefined` if `sync: true` is set. Thus, you _must_ specify an `onReadEntry`\nmethod in order to do anything useful with the data it parses.\n\nThe following options are supported:\n\n- `file` The archive file to list. If not specified, then a\n Writable stream is returned where the archive data should be\n written. [Alias: `f`]\n- `sync` Read the specified file synchronously. (This has no effect\n when a file option isn't specified, because entries are emitted as\n fast as they are parsed from the stream anyway.)\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `filter` A function that gets called with `(path, entry)` for each\n entry being listed. Return `true` to emit the entry from the\n archive, or `false` to skip it.\n- `onReadEntry` A function that gets called with `(entry)` for each entry\n that passes the filter. This is important for when `file` is set,\n because there is no other way to do anything useful with this method.\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 16 MB.\n- `noResume` By default, `entry` streams are resumed immediately after\n the call to `onReadEntry`. Set `noResume: true` to suppress this\n behavior. Note that by opting into this, the stream will never\n complete until the entry data is consumed.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n\n### tar.u(options, fileList, callback) [alias: tar.update]\n\nAdd files to an archive if they are newer than the entry already in\nthe tarball archive.\n\nThe `fileList` is an array of paths to add to the tarball. Adding a\ndirectory also adds its children recursively.\n\nAn entry in `fileList` that starts with an `@` symbol is a tar archive\nwhose entries will be added. To add a file that starts with `@`,\nprepend it with `./`.\n\nThe following options are supported:\n\n- `file` Required. Write the tarball archive to the specified\n filename. [Alias: `f`]\n- `sync` Act synchronously. If this is set, then any provided file\n will be fully written after the call to `tar.c`.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `cwd` The current working directory for adding entries to the\n archive. Defaults to `process.cwd()`. [Alias: `C`]\n- `prefix` A path portion to prefix onto the entries in the archive.\n- `gzip` Set to any truthy value to create a gzipped archive, or an\n object with settings for `zlib.Gzip()` [Alias: `z`]\n- `filter` A function that gets called with `(path, stat)` for each\n entry being added. Return `true` to add the entry to the archive,\n or `false` to omit it.\n- `portable` Omit metadata that is system-specific: `ctime`, `atime`,\n `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note\n that `mtime` is still included, because this is necessary for other\n time-based operations. Additionally, `mode` is set to a \"reasonable\n default\" for most unix systems, based on a `umask` value of `0o22`.\n- `preservePaths` Allow absolute paths. By default, `/` is stripped\n from absolute paths. [Alias: `P`]\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 16 MB.\n- `noDirRecurse` Do not recursively archive the contents of\n directories. [Alias: `n`]\n- `follow` Set to true to pack the targets of symbolic links. Without\n this option, symbolic links are archived as such. [Alias: `L`, `h`]\n- `noPax` Suppress pax extended headers. Note that this means that\n long paths and linkpaths will be truncated, and large or negative\n numeric values may be interpreted incorrectly.\n- `noMtime` Set to true to omit writing `mtime` values for entries.\n Note that this prevents using other mtime-based features like\n `tar.update` or the `keepNewer` option with the resulting tar archive.\n [Alias: `m`, `no-mtime`]\n- `mtime` Set to a `Date` object to force a specific `mtime` for\n everything added to the archive. Overridden by `noMtime`.\n- `onWriteEntry` Called with each `WriteEntry` or\n `WriteEntrySync` that is created in the course of writing the\n archive.\n\n### tar.r(options, fileList, callback) [alias: tar.replace]\n\nAdd files to an existing archive. Because later entries override\nearlier entries, this effectively replaces any existing entries.\n\nThe `fileList` is an array of paths to add to the tarball. Adding a\ndirectory also adds its children recursively.\n\nAn entry in `fileList` that starts with an `@` symbol is a tar archive\nwhose entries will be added. To add a file that starts with `@`,\nprepend it with `./`.\n\nThe following options are supported:\n\n- `file` Required. Write the tarball archive to the specified\n filename. [Alias: `f`]\n- `sync` Act synchronously. If this is set, then any provided file\n will be fully written after the call to `tar.c`.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `cwd` The current working directory for adding entries to the\n archive. Defaults to `process.cwd()`. [Alias: `C`]\n- `prefix` A path portion to prefix onto the entries in the archive.\n- `gzip` Set to any truthy value to create a gzipped archive, or an\n object with settings for `zlib.Gzip()` [Alias: `z`]\n- `filter` A function that gets called with `(path, stat)` for each\n entry being added. Return `true` to add the entry to the archive,\n or `false` to omit it.\n- `portable` Omit metadata that is system-specific: `ctime`, `atime`,\n `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note\n that `mtime` is still included, because this is necessary for other\n time-based operations. Additionally, `mode` is set to a \"reasonable\n default\" for most unix systems, based on a `umask` value of `0o22`.\n- `preservePaths` Allow absolute paths. By default, `/` is stripped\n from absolute paths. [Alias: `P`]\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 16 MB.\n- `noDirRecurse` Do not recursively archive the contents of\n directories. [Alias: `n`]\n- `follow` Set to true to pack the targets of symbolic links. Without\n this option, symbolic links are archived as such. [Alias: `L`, `h`]\n- `noPax` Suppress pax extended headers. Note that this means that\n long paths and linkpaths will be truncated, and large or negative\n numeric values may be interpreted incorrectly.\n- `noMtime` Set to true to omit writing `mtime` values for entries.\n Note that this prevents using other mtime-based features like\n `tar.update` or the `keepNewer` option with the resulting tar archive.\n [Alias: `m`, `no-mtime`]\n- `mtime` Set to a `Date` object to force a specific `mtime` for\n everything added to the archive. Overridden by `noMtime`.\n- `onWriteEntry` Called with each `WriteEntry` or\n `WriteEntrySync` that is created in the course of writing the\n archive.\n\n## Low-Level API\n\n### class Pack\n\nA readable tar stream.\n\nHas all the standard readable stream interface stuff. `'data'` and\n`'end'` events, `read()` method, `pause()` and `resume()`, etc.\n\n#### constructor(options)\n\nThe following options are supported:\n\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `cwd` The current working directory for creating the archive.\n Defaults to `process.cwd()`.\n- `prefix` A path portion to prefix onto the entries in the archive.\n- `gzip` Set to any truthy value to create a gzipped archive, or an\n object with settings for `zlib.Gzip()`\n- `filter` A function that gets called with `(path, stat)` for each\n entry being added. Return `true` to add the entry to the archive,\n or `false` to omit it.\n- `portable` Omit metadata that is system-specific: `ctime`, `atime`,\n `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note\n that `mtime` is still included, because this is necessary for other\n time-based operations. Additionally, `mode` is set to a \"reasonable\n default\" for most unix systems, based on a `umask` value of `0o22`.\n- `preservePaths` Allow absolute paths. By default, `/` is stripped\n from absolute paths.\n- `linkCache` A Map object containing the device and inode value for\n any file whose nlink is > 1, to identify hard links.\n- `statCache` A Map object that caches calls `lstat`.\n- `readdirCache` A Map object that caches calls to `readdir`.\n- `jobs` A number specifying how many concurrent jobs to run.\n Defaults to 4.\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 16 MB.\n- `noDirRecurse` Do not recursively archive the contents of\n directories.\n- `follow` Set to true to pack the targets of symbolic links. Without\n this option, symbolic links are archived as such.\n- `noPax` Suppress pax extended headers. Note that this means that\n long paths and linkpaths will be truncated, and large or negative\n numeric values may be interpreted incorrectly.\n- `noMtime` Set to true to omit writing `mtime` values for entries.\n Note that this prevents using other mtime-based features like\n `tar.update` or the `keepNewer` option with the resulting tar archive.\n- `mtime` Set to a `Date` object to force a specific `mtime` for\n everything added to the archive. Overridden by `noMtime`.\n- `onWriteEntry` Called with each `WriteEntry` or\n `WriteEntrySync` that is created in the course of writing the\n archive.\n\n#### add(path)\n\nAdds an entry to the archive. Returns the Pack stream.\n\n#### write(path)\n\nAdds an entry to the archive. Returns true if flushed.\n\n#### end()\n\nFinishes the archive.\n\n### class PackSync\n\nSynchronous version of `Pack`.\n\n### class Unpack\n\nA writable stream that unpacks a tar archive onto the file system.\n\nAll the normal writable stream stuff is supported. `write()` and\n`end()` methods, `'drain'` events, etc.\n\nNote that all directories that are created will be forced to be\nwritable, readable, and listable by their owner, to avoid cases where\na directory prevents extraction of child entries by virtue of its\nmode.\n\n`'close'` is emitted when it's done writing stuff to the file system.\n\nMost unpack errors will cause a `warn` event to be emitted. If the\n`cwd` is missing, or not a directory, then an error will be emitted.\n\n#### constructor(options)\n\n- `cwd` Extract files relative to the specified directory. Defaults\n to `process.cwd()`. If provided, this must exist and must be a\n directory.\n- `filter` A function that gets called with `(path, entry)` for each\n entry being unpacked. Return `true` to unpack the entry from the\n archive, or `false` to skip it.\n- `newer` Set to true to keep the existing file on disk if it's newer\n than the file in the archive.\n- `keep` Do not overwrite existing files. In particular, if a file\n appears more than once in an archive, later copies will not\n overwrite earlier copies.\n- `preservePaths` Allow absolute paths, paths containing `..`, and\n extracting through symbolic links. By default, `/` is stripped from\n absolute paths, `..` paths are not extracted, and any file whose\n location would be modified by a symbolic link is not extracted.\n- `unlink` Unlink files before creating them. Without this option,\n tar overwrites existing files, which preserves existing hardlinks.\n With this option, existing hardlinks will be broken, as will any\n symlink that would affect the location of an extracted file.\n- `strip` Remove the specified number of leading path elements.\n Pathnames with fewer elements will be silently skipped. Note that\n the pathname is edited after applying the filter, but before\n security checks.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `umask` Filter the modes of entries like `process.umask()`.\n- `dmode` Default mode for directories\n- `fmode` Default mode for files\n- `dirCache` A Map object of which directories exist.\n- `maxMetaEntrySize` The maximum size of meta entries that is\n supported. Defaults to 1 MB.\n- `preserveOwner` If true, tar will set the `uid` and `gid` of\n extracted entries to the `uid` and `gid` fields in the archive.\n This defaults to true when run as root, and false otherwise. If\n false, then files and directories will be set with the owner and\n group of the user running the process. This is similar to `-p` in\n `tar(1)`, but ACLs and other system-specific data is never unpacked\n in this implementation, and modes are set by default already.\n- `win32` True if on a windows platform. Causes behavior where\n filenames containing `<|>?` chars are converted to\n windows-compatible values while being unpacked.\n- `uid` Set to a number to force ownership of all extracted files and\n folders, and all implicitly created directories, to be owned by the\n specified user id, regardless of the `uid` field in the archive.\n Cannot be used along with `preserveOwner`. Requires also setting a\n `gid` option.\n- `gid` Set to a number to force ownership of all extracted files and\n folders, and all implicitly created directories, to be owned by the\n specified group id, regardless of the `gid` field in the archive.\n Cannot be used along with `preserveOwner`. Requires also setting a\n `uid` option.\n- `noMtime` Set to true to omit writing `mtime` value for extracted\n entries.\n- `transform` Provide a function that takes an `entry` object, and\n returns a stream, or any falsey value. If a stream is provided,\n then that stream's data will be written instead of the contents of\n the archive entry. If a falsey value is provided, then the entry is\n written to disk as normal. (To exclude items from extraction, use\n the `filter` option described above.)\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `onReadEntry` A function that gets called with `(entry)` for each entry\n that passes the filter.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `chmod` Set to true to call `fs.chmod()` to ensure that the\n extracted file matches the entry mode. This may necessitate a\n call to the deprecated and thread-unsafe `process.umask()`\n method to determine the default umask value, unless a\n `processUmask` options is also provided. Otherwise tar will\n extract with whatever mode is provided, and let the process\n `umask` apply normally.\n- `processUmask` Set to an explicit numeric value to avoid\n calling `process.umask()` when `chmod: true` is set.\n- `maxDepth` The maximum depth of subfolders to extract into. This\n defaults to 1024. Anything deeper than the limit will raise a\n warning and skip the entry. Set to `Infinity` to remove the\n limitation.\n\n### class UnpackSync\n\nSynchronous version of `Unpack`.\n\nNote that using an asynchronous stream type with the `transform`\noption will cause undefined behavior in sync unpack streams.\n[MiniPass](http://npm.im/minipass)-based streams are designed for this\nuse case.\n\n### class tar.Parse\n\nA writable stream that parses a tar archive stream. All the standard\nwritable stream stuff is supported.\n\nIf the archive is gzipped, then tar will detect this and unzip it.\n\nEmits `'entry'` events with `tar.ReadEntry` objects, which are\nthemselves readable streams that you can pipe wherever.\n\nEach `entry` will not emit until the one before it is flushed through,\nso make sure to either consume the data (with `on('data', ...)` or\n`.pipe(...)`) or throw it away with `.resume()` to keep the stream\nflowing.\n\n#### constructor(options)\n\nReturns an event emitter that emits `entry` events with\n`tar.ReadEntry` objects.\n\nThe following options are supported:\n\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `filter` A function that gets called with `(path, entry)` for each\n entry being listed. Return `true` to emit the entry from the\n archive, or `false` to skip it.\n- `onReadEntry` A function that gets called with `(entry)` for each entry\n that passes the filter.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n\n#### abort(error)\n\nStop all parsing activities. This is called when there are zlib\nerrors. It also emits an unrecoverable warning with the error provided.\n\n### class tar.ReadEntry extends [MiniPass](http://npm.im/minipass)\n\nA representation of an entry that is being read out of a tar archive.\n\nIt has the following fields:\n\n- `extended` The extended metadata object provided to the constructor.\n- `globalExtended` The global extended metadata object provided to the\n constructor.\n- `remain` The number of bytes remaining to be written into the\n stream.\n- `blockRemain` The number of 512-byte blocks remaining to be written\n into the stream.\n- `ignore` Whether this entry should be ignored.\n- `meta` True if this represents metadata about the next entry, false\n if it represents a filesystem object.\n- All the fields from the header, extended header, and global extended\n header are added to the ReadEntry object. So it has `path`, `type`,\n `size`, `mode`, and so on.\n\n#### constructor(header, extended, globalExtended)\n\nCreate a new ReadEntry object with the specified header, extended\nheader, and global extended header values.\n\n### class tar.WriteEntry extends [MiniPass](http://npm.im/minipass)\n\nA representation of an entry that is being written from the file\nsystem into a tar archive.\n\nEmits data for the Header, and for the Pax Extended Header if one is\nrequired, as well as any body data.\n\nCreating a WriteEntry for a directory does not also create\nWriteEntry objects for all of the directory contents.\n\nIt has the following fields:\n\n- `path` The path field that will be written to the archive. By\n default, this is also the path from the cwd to the file system\n object.\n- `portable` Omit metadata that is system-specific: `ctime`, `atime`,\n `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note\n that `mtime` is still included, because this is necessary for other\n time-based operations. Additionally, `mode` is set to a \"reasonable\n default\" for most unix systems, based on a `umask` value of `0o22`.\n- `myuid` If supported, the uid of the user running the current\n process.\n- `myuser` The `env.USER` string if set, or `''`. Set as the entry\n `uname` field if the file's `uid` matches `this.myuid`.\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 1 MB.\n- `linkCache` A Map object containing the device and inode value for\n any file whose nlink is > 1, to identify hard links.\n- `statCache` A Map object that caches calls `lstat`.\n- `preservePaths` Allow absolute paths. By default, `/` is stripped\n from absolute paths.\n- `cwd` The current working directory for creating the archive.\n Defaults to `process.cwd()`.\n- `absolute` The absolute path to the entry on the filesystem. By\n default, this is `path.resolve(this.cwd, this.path)`, but it can be\n overridden explicitly.\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `win32` True if on a windows platform. Causes behavior where paths\n replace `\\` with `/` and filenames containing the windows-compatible\n forms of `<|>?:` characters are converted to actual `<|>?:` characters\n in the archive.\n- `noPax` Suppress pax extended headers. Note that this means that\n long paths and linkpaths will be truncated, and large or negative\n numeric values may be interpreted incorrectly.\n- `noMtime` Set to true to omit writing `mtime` values for entries.\n Note that this prevents using other mtime-based features like\n `tar.update` or the `keepNewer` option with the resulting tar archive.\n\n#### constructor(path, options)\n\n`path` is the path of the entry as it is written in the archive.\n\nThe following options are supported:\n\n- `portable` Omit metadata that is system-specific: `ctime`, `atime`,\n `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note\n that `mtime` is still included, because this is necessary for other\n time-based operations. Additionally, `mode` is set to a \"reasonable\n default\" for most unix systems, based on a `umask` value of `0o22`.\n- `maxReadSize` The maximum buffer size for `fs.read()` operations.\n Defaults to 1 MB.\n- `linkCache` A Map object containing the device and inode value for\n any file whose nlink is > 1, to identify hard links.\n- `statCache` A Map object that caches calls `lstat`.\n- `preservePaths` Allow absolute paths. By default, `/` is stripped\n from absolute paths.\n- `cwd` The current working directory for creating the archive.\n Defaults to `process.cwd()`.\n- `absolute` The absolute path to the entry on the filesystem. By\n default, this is `path.resolve(this.cwd, this.path)`, but it can be\n overridden explicitly.\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `win32` True if on a windows platform. Causes behavior where paths\n replace `\\` with `/`.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `noMtime` Set to true to omit writing `mtime` values for entries.\n Note that this prevents using other mtime-based features like\n `tar.update` or the `keepNewer` option with the resulting tar archive.\n- `umask` Set to restrict the modes on the entries in the archive,\n somewhat like how umask works on file creation. Defaults to\n `process.umask()` on unix systems, or `0o22` on Windows.\n\n#### warn(message, data)\n\nIf strict, emit an error with the provided message.\n\nOthewise, emit a `'warn'` event with the provided message and data.\n\n### class tar.WriteEntry.Sync\n\nSynchronous version of tar.WriteEntry\n\n### class tar.WriteEntry.Tar\n\nA version of tar.WriteEntry that gets its data from a tar.ReadEntry\ninstead of from the filesystem.\n\n#### constructor(readEntry, options)\n\n`readEntry` is the entry being read out of another archive.\n\nThe following options are supported:\n\n- `portable` Omit metadata that is system-specific: `ctime`, `atime`,\n `uid`, `gid`, `uname`, `gname`, `dev`, `ino`, and `nlink`. Note\n that `mtime` is still included, because this is necessary for other\n time-based operations. Additionally, `mode` is set to a \"reasonable\n default\" for most unix systems, based on a `umask` value of `0o22`.\n- `preservePaths` Allow absolute paths. By default, `/` is stripped\n from absolute paths.\n- `strict` Treat warnings as crash-worthy errors. Default false.\n- `onwarn` A function that will get called with `(code, message, data)` for\n any warnings encountered. (See \"Warnings and Errors\")\n- `noMtime` Set to true to omit writing `mtime` values for entries.\n Note that this prevents using other mtime-based features like\n `tar.update` or the `keepNewer` option with the resulting tar archive.\n\n### class tar.Header\n\nA class for reading and writing header blocks.\n\nIt has the following fields:\n\n- `nullBlock` True if decoding a block which is entirely composed of\n `0x00` null bytes. (Useful because tar files are terminated by\n at least 2 null blocks.)\n- `cksumValid` True if the checksum in the header is valid, false\n otherwise.\n- `needPax` True if the values, as encoded, will require a Pax\n extended header.\n- `path` The path of the entry.\n- `mode` The 4 lowest-order octal digits of the file mode. That is,\n read/write/execute permissions for world, group, and owner, and the\n setuid, setgid, and sticky bits.\n- `uid` Numeric user id of the file owner\n- `gid` Numeric group id of the file owner\n- `size` Size of the file in bytes\n- `mtime` Modified time of the file\n- `cksum` The checksum of the header. This is generated by adding all\n the bytes of the header block, treating the checksum field itself as\n all ascii space characters (that is, `0x20`).\n- `type` The human-readable name of the type of entry this represents,\n or the alphanumeric key if unknown.\n- `typeKey` The alphanumeric key for the type of entry this header\n represents.\n- `linkpath` The target of Link and SymbolicLink entries.\n- `uname` Human-readable user name of the file owner\n- `gname` Human-readable group name of the file owner\n- `devmaj` The major portion of the device number. Always `0` for\n files, directories, and links.\n- `devmin` The minor portion of the device number. Always `0` for\n files, directories, and links.\n- `atime` File access time.\n- `ctime` File change time.\n\n#### constructor(data, [offset=0])\n\n`data` is optional. It is either a Buffer that should be interpreted\nas a tar Header starting at the specified offset and continuing for\n512 bytes, or a data object of keys and values to set on the header\nobject, and eventually encode as a tar Header.\n\n#### decode(block, offset)\n\nDecode the provided buffer starting at the specified offset.\n\nBuffer length must be greater than 512 bytes.\n\n#### set(data)\n\nSet the fields in the data object.\n\n#### encode(buffer, offset)\n\nEncode the header fields into the buffer at the specified offset.\n\nReturns `this.needPax` to indicate whether a Pax Extended Header is\nrequired to properly encode the specified data.\n\n### class tar.Pax\n\nAn object representing a set of key-value pairs in an Pax extended\nheader entry.\n\nIt has the following fields. Where the same name is used, they have\nthe same semantics as the tar.Header field of the same name.\n\n- `global` True if this represents a global extended header, or false\n if it is for a single entry.\n- `atime`\n- `charset`\n- `comment`\n- `ctime`\n- `gid`\n- `gname`\n- `linkpath`\n- `mtime`\n- `path`\n- `size`\n- `uid`\n- `uname`\n- `dev`\n- `ino`\n- `nlink`\n\n#### constructor(object, global)\n\nSet the fields set in the object. `global` is a boolean that defaults\nto false.\n\n#### encode()\n\nReturn a Buffer containing the header and body for the Pax extended\nheader entry, or `null` if there is nothing to encode.\n\n#### encodeBody()\n\nReturn a string representing the body of the pax extended header\nentry.\n\n#### encodeField(fieldName)\n\nReturn a string representing the key/value encoding for the specified\nfieldName, or `''` if the field is unset.\n\n### tar.Pax.parse(string, extended, global)\n\nReturn a new Pax object created by parsing the contents of the string\nprovided.\n\nIf the `extended` object is set, then also add the fields from that\nobject. (This is necessary because multiple metadata entries can\noccur in sequence.)\n\n### tar.types\n\nA translation table for the `type` field in tar headers.\n\n#### tar.types.name.get(code)\n\nGet the human-readable name for a given alphanumeric code.\n\n#### tar.types.code.get(name)\n\nGet the alphanumeric code for a given human-readable name.\n","readmeFilename":"README.md"}
|