1 |
|
2 |
|
3 | import stream = require("stream");
|
4 | import zlib = require("zlib");
|
5 | import MiniPass = require("minipass");
|
6 | import fs = require("fs");
|
7 |
|
8 |
|
9 |
|
10 | export interface HeaderProperties {
|
11 | path: string;
|
12 | mode?: number | undefined;
|
13 | noProprietary?: boolean | undefined;
|
14 | uid?: number | undefined;
|
15 | gid?: number | undefined;
|
16 | size?: number | undefined;
|
17 | mtime?: number | undefined;
|
18 | type?: string | undefined;
|
19 | uname?: string | undefined;
|
20 | gname?: string | undefined;
|
21 | devmaj?: number | undefined;
|
22 | devmin?: number | undefined;
|
23 | }
|
24 |
|
25 | export interface ExtractOptions {
|
26 | type?: string | undefined;
|
27 | Directory?: boolean | undefined;
|
28 | path?: string | undefined;
|
29 | strip?: number | undefined;
|
30 | }
|
31 |
|
32 | export interface ParseStream extends NodeJS.ReadWriteStream {
|
33 | position: number;
|
34 |
|
35 | _stream: stream.Stream;
|
36 | _ended: boolean;
|
37 |
|
38 | _streamEnd(): void;
|
39 | _process(c: Buffer): void;
|
40 | _startEntry(c: Buffer): void;
|
41 | }
|
42 |
|
43 | export interface PackStream extends NodeJS.ReadWriteStream {
|
44 | writable: boolean;
|
45 | readable: boolean;
|
46 |
|
47 | _noProprietary: boolean;
|
48 | _global: HeaderProperties;
|
49 | _buffer: stream.Stream[];
|
50 | _currentEntry: any;
|
51 | _processing: boolean;
|
52 | _pipeRoot: stream.Stream;
|
53 | _needDrain: boolean;
|
54 | _paused: boolean;
|
55 |
|
56 | addGlobal(props: HeaderProperties): void;
|
57 | add(stream: stream.Stream): boolean;
|
58 | destroy(): void;
|
59 |
|
60 | _process(): void;
|
61 | }
|
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | export interface Fields {
|
68 | path: number;
|
69 | mode: number;
|
70 | uid: number;
|
71 | gid: number;
|
72 | size: number;
|
73 | mtime: number;
|
74 | cksum: number;
|
75 | type: number;
|
76 | linkpath: number;
|
77 | ustar: number;
|
78 | ustarvar: number;
|
79 | uname: number;
|
80 | gname: number;
|
81 | devmaj: number;
|
82 | devmin: number;
|
83 | prefix: number;
|
84 | fill: number;
|
85 | }
|
86 |
|
87 | export type fields = Fields;
|
88 |
|
89 | export const fieldSize: number[];
|
90 | export const fieldOffs: number[];
|
91 | export const fieldEnds: number[];
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 | export const types: {
|
98 | 0: string;
|
99 | "\0": string;
|
100 | "": string;
|
101 | 1: string;
|
102 | 2: string;
|
103 | 3: string;
|
104 | 4: string;
|
105 | 5: string;
|
106 | 6: string;
|
107 | 7: string;
|
108 | g: string;
|
109 | x: string;
|
110 | A: string;
|
111 | D: string;
|
112 | I: string;
|
113 | K: string;
|
114 | L: string;
|
115 | M: string;
|
116 | N: string;
|
117 | S: string;
|
118 | V: string;
|
119 | X: string;
|
120 | File: string;
|
121 | OldFile: string;
|
122 | Link: string;
|
123 | SymbolicLick: string;
|
124 | CharacterDevice: string;
|
125 | BlockDevice: string;
|
126 | Directory: string;
|
127 | FIFO: string;
|
128 | ContiguousFile: string;
|
129 | GlobalExtendedHeader: string;
|
130 | ExtendedHeader: string;
|
131 | SolarisACL: string;
|
132 | GNUDumpDir: string;
|
133 | INode: string;
|
134 | NextFileHasLonLinkPath: string;
|
135 | NextFileHasLongPath: string;
|
136 | ContinuationFile: string;
|
137 | TapeVolumeHeader: string;
|
138 | OldExtendedHeader: string;
|
139 | };
|
140 |
|
141 |
|
142 |
|
143 |
|
144 | export const modes: {
|
145 | suid: number;
|
146 | sgid: number;
|
147 | svtx: number;
|
148 | uread: number;
|
149 | uwrite: number;
|
150 | uexec: number;
|
151 | gread: number;
|
152 | gwrite: number;
|
153 | gexec: number;
|
154 | oread: number;
|
155 | owrite: number;
|
156 | oexec: number;
|
157 | };
|
158 |
|
159 | export const numeric: {
|
160 | mode: boolean;
|
161 | uid: boolean;
|
162 | gid: boolean;
|
163 | size: boolean;
|
164 | mtime: boolean;
|
165 | devmaj: boolean;
|
166 | devmin: boolean;
|
167 | cksum: boolean;
|
168 | atime: boolean;
|
169 | ctime: boolean;
|
170 | dev: boolean;
|
171 | ino: boolean;
|
172 | nlink: boolean;
|
173 | };
|
174 |
|
175 | export const knownExtended: {
|
176 | atime: boolean;
|
177 | charset: boolean;
|
178 | comment: boolean;
|
179 | ctime: boolean;
|
180 | gid: boolean;
|
181 | gname: boolean;
|
182 | linkpat: boolean;
|
183 | mtime: boolean;
|
184 | path: boolean;
|
185 | realtime: boolean;
|
186 | security: boolean;
|
187 | size: boolean;
|
188 | uid: boolean;
|
189 | uname: boolean;
|
190 | };
|
191 |
|
192 | export const headerSize: number;
|
193 | export const blockSize: number;
|
194 |
|
195 | export interface ParseOptions {
|
196 | strict?: boolean;
|
197 | filter?: (path: string, entry: ReadEntry) => boolean;
|
198 | onentry?: (entry: ReadEntry) => void;
|
199 | onwarn?: (code: string, message: string, data: Buffer) => void;
|
200 | }
|
201 |
|
202 |
|
203 |
|
204 | export interface Parse extends ParseStream {
|
205 | on(event: "end" | "close", listener: () => void): this;
|
206 | on(event: "entry", listener: (entry: ReadEntry) => void): this;
|
207 | }
|
208 |
|
209 | export const Parse: {
|
210 | new(opt?: ParseOptions): Parse;
|
211 | };
|
212 |
|
213 |
|
214 |
|
215 |
|
216 | export interface PackOptions {
|
217 | |
218 |
|
219 |
|
220 |
|
221 | onwarn?(code: string, message: string, data: Buffer): void;
|
222 | |
223 |
|
224 |
|
225 |
|
226 |
|
227 | strict?: boolean;
|
228 | |
229 |
|
230 |
|
231 |
|
232 |
|
233 | cwd?: string;
|
234 | |
235 |
|
236 |
|
237 | prefix?: string;
|
238 | |
239 |
|
240 |
|
241 |
|
242 | gzip?: boolean | zlib.ZlibOptions;
|
243 | |
244 |
|
245 |
|
246 |
|
247 | filter?(path: string, stat: fs.Stats): boolean;
|
248 | |
249 |
|
250 |
|
251 |
|
252 |
|
253 |
|
254 |
|
255 | portable?: boolean;
|
256 | |
257 |
|
258 |
|
259 | preservePaths?: boolean;
|
260 | |
261 |
|
262 |
|
263 |
|
264 | linkCache?: Map<string, string>;
|
265 | |
266 |
|
267 |
|
268 | statCache?: Map<string, string>;
|
269 | |
270 |
|
271 |
|
272 | readdirCache?: Map<string, string>;
|
273 | |
274 |
|
275 |
|
276 |
|
277 |
|
278 | jobs?: number;
|
279 | |
280 |
|
281 |
|
282 |
|
283 |
|
284 | maxReadSize?: number;
|
285 | |
286 |
|
287 |
|
288 | noDirRecurse?: boolean;
|
289 | |
290 |
|
291 |
|
292 |
|
293 | follow?: boolean;
|
294 | |
295 |
|
296 |
|
297 |
|
298 |
|
299 | noPax?: boolean;
|
300 | |
301 |
|
302 |
|
303 |
|
304 |
|
305 | noMtime?: boolean;
|
306 | |
307 |
|
308 |
|
309 |
|
310 | mtime?: number;
|
311 | }
|
312 |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 |
|
318 | export class Pack extends MiniPass {
|
319 | linkCache: PackOptions["linkCache"];
|
320 | readdirCache: PackOptions["readdirCache"];
|
321 | statCache: PackOptions["statCache"];
|
322 |
|
323 | static Sync: typeof PackSync;
|
324 |
|
325 | constructor(opt?: PackOptions);
|
326 |
|
327 | add(path: string): this;
|
328 | }
|
329 |
|
330 | declare class PackSync extends Pack {
|
331 | constructor(opt: PackOptions);
|
332 |
|
333 | // pause/resume are no-ops in sync streams.
|
334 | pause(): void;
|
335 | resume(): void;
|
336 | }
|
337 |
|
338 | declare class PackJob {
|
339 | path: string;
|
340 | absolute: string;
|
341 | entry: unknown | null;
|
342 | stat: unknown | null;
|
343 | readdir: unknown | null;
|
344 | pending: boolean;
|
345 | ignore: boolean;
|
346 | piped: boolean;
|
347 |
|
348 | constructor(path?: string, absolute?: string);
|
349 | }
|
350 |
|
351 | /**
|
352 | * Returns a through stream. Write tar data to the stream and the files in the tarball will be extracted onto the filesystem.
|
353 | * options can be:
|
354 | * ```
|
355 | * {
|
356 | * path: '/path/to/extract/tar/into',
|
357 | * strip: 0,
|
358 | * }
|
359 | * ```
|
360 | * options also get passed to the fstream.Writer instance that tar uses internally.
|
361 | */
|
362 | export function Extract(opts: ExtractOptions | string): ParseStream;
|
363 |
|
364 | export interface FileStat extends stream.Readable, Fields {
|
365 | header: HeaderProperties;
|
366 | startBlockSize: number;
|
367 | blockRemain: number;
|
368 | remain: number;
|
369 | meta: boolean;
|
370 | ignore: boolean;
|
371 | size: number;
|
372 | }
|
373 |
|
374 | export interface ReadEntry extends MiniPass, HeaderProperties {
|
375 | /** The extended metadata object provided to the constructor. */
|
376 | extended: any;
|
377 | /** The global extended metadata object provided to the constructor. */
|
378 | globalExtended: any;
|
379 | /** The number of bytes remaining to be written into the stream. */
|
380 | remain: number;
|
381 | /** The number of 512-byte blocks remaining to be written into the stream. */
|
382 | blockRemain: number;
|
383 | /** Whether this entry should be ignored. */
|
384 | ignore: boolean;
|
385 | /**
|
386 | * True if this represents metadata about the next entry, false if it
|
387 | * represents a filesystem object.
|
388 | */
|
389 | meta: boolean;
|
390 | }
|
391 |
|
392 | export interface CreateOptions {
|
393 | /**
|
394 | * A function that will get called with (code, message, data) for any
|
395 | * warnings encountered. (See "Warnings and Errors")
|
396 | */
|
397 | onwarn?(code: string, message: string, data: Buffer): void;
|
398 |
|
399 | /**
|
400 | * Treat warnings as crash-worthy errors. Default false.
|
401 | */
|
402 | strict?: boolean | undefined;
|
403 |
|
404 | /**
|
405 | * The current working directory for creating the archive. Defaults to process.cwd().
|
406 | */
|
407 | cwd?: string | undefined;
|
408 |
|
409 | /**
|
410 | * Alias for cwd.
|
411 | */
|
412 | C?: string | undefined;
|
413 |
|
414 | /**
|
415 | * Set to any truthy value to create a gzipped archive,
|
416 | * or an object with settings for zlib.Gzip()
|
417 | */
|
418 | gzip?: boolean | zlib.ZlibOptions | undefined;
|
419 |
|
420 | /**
|
421 | * Alias for gzip.
|
422 | */
|
423 | z?: boolean | zlib.ZlibOptions | undefined;
|
424 |
|
425 | /**
|
426 | * A function that gets called with (path, stat) for each entry being
|
427 | * added. Return true to add the entry to the archive, or false to omit it.
|
428 | */
|
429 | filter?(path: string, stat: fs.Stats): boolean;
|
430 |
|
431 | /**
|
432 | * Omit metadata that is system-specific: ctime, atime, uid, gid, uname,
|
433 | * gname, dev, ino, and nlink. Note that mtime is still included,
|
434 | * because this is necessary other time-based operations.
|
435 | */
|
436 | portable?: boolean | undefined;
|
437 |
|
438 | /**
|
439 | * Allow absolute paths. By default, / is stripped from absolute paths.
|
440 | */
|
441 | preservePaths?: boolean | undefined;
|
442 |
|
443 | /**
|
444 | * Alias for presevePaths.
|
445 | */
|
446 | P?: boolean | undefined;
|
447 |
|
448 | /**
|
449 | * The mode to set on the created file archive.
|
450 | */
|
451 | mode?: number | undefined;
|
452 |
|
453 | /**
|
454 | * Do not recursively archive the contents of directories.
|
455 | */
|
456 | noDirRecurse?: boolean | undefined;
|
457 |
|
458 | /**
|
459 | * Set to true to pack the targets of symbolic links. Without this
|
460 | * option, symbolic links are archived as such.
|
461 | */
|
462 | follow?: boolean | undefined;
|
463 |
|
464 | /**
|
465 | * Alias for follow.
|
466 | */
|
467 | L?: boolean | undefined;
|
468 |
|
469 | /**
|
470 | * Alias for follow.
|
471 | */
|
472 | h?: boolean | undefined;
|
473 |
|
474 | /**
|
475 | * Suppress pax extended headers. Note that this means that long paths and
|
476 | * linkpaths will be truncated, and large or negative numeric values
|
477 | * may be interpreted incorrectly.
|
478 | */
|
479 | noPax?: boolean | undefined;
|
480 |
|
481 | /**
|
482 | * A path portion to prefix onto the entries in the archive.
|
483 | */
|
484 | prefix?: string | undefined;
|
485 | }
|
486 |
|
487 | export interface ExtractOptions {
|
488 | /**
|
489 | * A function that will get called with (code, message, data) for any
|
490 | * warnings encountered. (See "Warnings and Errors")
|
491 | */
|
492 | onwarn?(code: string, message: string, data: Buffer): void;
|
493 |
|
494 | /**
|
495 | * Treat warnings as crash-worthy errors. Default false.
|
496 | */
|
497 | strict?: boolean | undefined;
|
498 |
|
499 | /**
|
500 | * Extract files relative to the specified directory. Defaults to
|
501 | * process.cwd(). If provided, this must exist and must be a directory.
|
502 | */
|
503 | cwd?: string | undefined;
|
504 |
|
505 | /**
|
506 | * Alias for cwd.
|
507 | */
|
508 | C?: string | undefined;
|
509 |
|
510 | /**
|
511 | * A function that gets called with (path, stat) for each entry being
|
512 | * added. Return true to emit the entry from the archive, or false to skip it.
|
513 | */
|
514 | filter?(path: string, stat: FileStat): boolean;
|
515 |
|
516 | /**
|
517 | * Set to true to keep the existing file on disk if it's newer than
|
518 | * the file in the archive.
|
519 | */
|
520 | newer?: boolean | undefined;
|
521 |
|
522 | /**
|
523 | * Alias for newer.
|
524 | */
|
525 | "keep-newer"?: boolean | undefined;
|
526 |
|
527 | /**
|
528 | * Alias for newer.
|
529 | */
|
530 | "keep-newer-files"?: boolean | undefined;
|
531 |
|
532 | /**
|
533 | * Do not overwrite existing files. In particular, if a file appears more
|
534 | * than once in an archive, later copies will not overwrite earlier copies
|
535 | */
|
536 | keep?: boolean | undefined;
|
537 |
|
538 | /**
|
539 | * Alias for keep.
|
540 | */
|
541 | k?: boolean | undefined;
|
542 |
|
543 | /**
|
544 | * Alias for keep.
|
545 | */
|
546 | "keep-existing"?: boolean | undefined;
|
547 |
|
548 | /**
|
549 | * Unlink files before creating them. Without this option, tar overwrites
|
550 | * existing files, which preserves existing hardlinks. With this option,
|
551 | * existing hardlinks will be broken, as will any symlink that would
|
552 | * affect the location of an extracted file.
|
553 | */
|
554 | unlink?: boolean | undefined;
|
555 |
|
556 | /**
|
557 | * Remove the specified number of leading path elements. Pathnames with
|
558 | * fewer elements will be silently skipped. Note that the pathname
|
559 | * is edited after applying the filter, but before security checks.
|
560 | */
|
561 | strip?: number | undefined;
|
562 |
|
563 | /**
|
564 | * Alias for strip.
|
565 | */
|
566 | "strip-components"?: number | undefined;
|
567 |
|
568 | /**
|
569 | * Alias for strip.
|
570 | */
|
571 | stripComponents?: number | undefined;
|
572 |
|
573 | /**
|
574 | * If true, tar will set the uid and gid of extracted entries to the uid
|
575 | * and gid fields in the archive. This defaults to true when run as root,
|
576 | * and false otherwise. If false, then files and directories will be set
|
577 | * with the owner and group of the user running the process. This is
|
578 | * similar to -p in tar(1), but ACLs and other system-specific data is
|
579 | * never unpacked in this implementation, and modes
|
580 | * are set by default already.
|
581 | */
|
582 | preserveOwner?: boolean | undefined;
|
583 |
|
584 | /**
|
585 | * Alias for preserveOwner.
|
586 | */
|
587 | p?: boolean | undefined;
|
588 |
|
589 | /**
|
590 | * Set to a number to force ownership of all extracted files and folders,
|
591 | * and all implicitly created directories, to be owned by the specified
|
592 | * user id, regardless of the uid field in the archive. Cannot be used
|
593 | * along with preserveOwner. Requires also setting a gid option.
|
594 | */
|
595 | uid?: number | undefined;
|
596 |
|
597 | /**
|
598 | * Set to a number to force ownership of all extracted files and folders,
|
599 | * and all implicitly created directories, to be owned by the specified
|
600 | * group id, regardless of the gid field in the archive. Cannot be used
|
601 | * along with preserveOwner. Requires also setting a uid option
|
602 | */
|
603 | gid?: number | undefined;
|
604 |
|
605 | /**
|
606 | * Set to true to omit writing mtime value for extracted entries.
|
607 | * [Alias: m, no-mtime]
|
608 | */
|
609 | noMtime?: boolean | undefined;
|
610 | m?: boolean | undefined;
|
611 | "no-mtime"?: boolean | undefined;
|
612 |
|
613 | /**
|
614 | * Provide a function that takes an entry object, and returns a stream,
|
615 | * or any falsey value. If a stream is provided, then that stream's data
|
616 | * will be written instead of the contents of the archive entry. If a
|
617 | * falsey value is provided, then the entry is written to disk as normal.
|
618 | * (To exclude items from extraction, use the filter option described above.)
|
619 | */
|
620 | transform?(entry: ReadEntry): NodeJS.WritableStream | undefined | false | null;
|
621 |
|
622 | /**
|
623 | * A function that gets called with (entry) for each entry that passes the
|
624 | * filter.
|
625 | */
|
626 | onentry?(entry: ReadEntry): void;
|
627 |
|
628 | /**
|
629 | * Set to true to omit calling `fs.chmod()` to ensure that the extracted file
|
630 | * matches the entry mode. This also suppresses the call to `process.umask()`
|
631 | * to determine the default umask value, since tar will extract with whatever
|
632 | * mode is provided, and let the process `umask` apply normally.
|
633 | */
|
634 | noChmod?: boolean | undefined;
|
635 |
|
636 | // The following options are mostly internal, but can be modified in some
|
637 | // advanced use cases, such as re-using caches between runs.
|
638 |
|
639 | /**
|
640 | * The maximum buffer size for fs.read() operations (in bytes). Defaults to 16 MB.
|
641 | */
|
642 | maxReadSize?: number | undefined;
|
643 |
|
644 | /**
|
645 | * The maximum size of meta entries that is supported. Defaults to 1 MB.
|
646 | */
|
647 | maxMetaEntrySize?: number | undefined;
|
648 | }
|
649 |
|
650 | export interface ListOptions {
|
651 | /**
|
652 | * Treat warnings as crash-worthy errors. Default false.
|
653 | */
|
654 | strict?: boolean | undefined;
|
655 |
|
656 | /**
|
657 | * Extract files relative to the specified directory. Defaults to
|
658 | * process.cwd(). If provided, this must exist and must be a directory.
|
659 | */
|
660 | cwd?: string | undefined;
|
661 |
|
662 | /**
|
663 | * Alias for cwd.
|
664 | */
|
665 | C?: string | undefined;
|
666 |
|
667 | /**
|
668 | * A function that gets called with (path, stat) for each entry being
|
669 | * added. Return true to emit the entry from the archive, or false to skip it.
|
670 | */
|
671 | filter?(path: string, entry: FileStat): boolean;
|
672 |
|
673 | /**
|
674 | * A function that gets called with (entry) for each entry that passes the
|
675 | * filter. This is important for when both file and sync are set, because
|
676 | * it will be called synchronously.
|
677 | */
|
678 | onentry?(entry: ReadEntry): void;
|
679 |
|
680 | /**
|
681 | * The maximum buffer size for fs.read() operations. Defaults to 16 MB.
|
682 | */
|
683 | maxReadSize?: number | undefined;
|
684 |
|
685 | /**
|
686 | * By default, entry streams are resumed immediately after the call to
|
687 | * onentry. Set noResume: true to suppress this behavior. Note that by
|
688 | * opting into this, the stream will never complete until the entry
|
689 | * data is consumed.
|
690 | */
|
691 | noResume?: boolean | undefined;
|
692 | }
|
693 |
|
694 | export interface ReplaceOptions {
|
695 | /**
|
696 | * Required. Write the tarball archive to the specified filename.
|
697 | */
|
698 | file: string;
|
699 |
|
700 | /**
|
701 | * Act synchronously. If this is set, then any provided file will be
|
702 | * fully written after the call to tar.c.
|
703 | */
|
704 | sync?: boolean | undefined;
|
705 |
|
706 | /**
|
707 | * A function that will get called with (code, message, data) for any
|
708 | * warnings encountered. (See "Warnings and Errors")
|
709 | */
|
710 | onwarn?(code: string, message: string, data: Buffer): void;
|
711 |
|
712 | /**
|
713 | * Treat warnings as crash-worthy errors. Default false.
|
714 | */
|
715 | strict?: boolean | undefined;
|
716 |
|
717 | /**
|
718 | * Extract files relative to the specified directory. Defaults to
|
719 | * process.cwd(). If provided, this must exist and must be a directory.
|
720 | */
|
721 | cwd?: string | undefined;
|
722 |
|
723 | /**
|
724 | * Alias for cwd.
|
725 | */
|
726 | C?: string | undefined;
|
727 |
|
728 | /**
|
729 | * A path portion to prefix onto the entries in the archive.
|
730 | */
|
731 | prefix?: string | undefined;
|
732 |
|
733 | /**
|
734 | * Set to any truthy value to create a gzipped archive,
|
735 | * or an object with settings for zlib.Gzip()
|
736 | */
|
737 | gzip?: boolean | zlib.ZlibOptions | undefined;
|
738 |
|
739 | /**
|
740 | * A function that gets called with (path, stat) for each entry being
|
741 | * added. Return true to emit the entry from the archive, or false to skip it.
|
742 | */
|
743 | filter?(path: string, stat: fs.Stats): boolean;
|
744 |
|
745 | /**
|
746 | * Allow absolute paths. By default, / is stripped from absolute paths.
|
747 | */
|
748 | preservePaths?: boolean | undefined;
|
749 |
|
750 | /**
|
751 | * The maximum buffer size for fs.read() operations. Defaults to 16 MB.
|
752 | */
|
753 | maxReadSize?: number | undefined;
|
754 |
|
755 | /**
|
756 | * Do not recursively archive the contents of directories.
|
757 | */
|
758 | noDirRecurse?: boolean | undefined;
|
759 |
|
760 | /**
|
761 | * Set to true to pack the targets of symbolic links. Without this
|
762 | * option, symbolic links are archived as such.
|
763 | */
|
764 | follow?: boolean | undefined;
|
765 |
|
766 | /**
|
767 | * Alias for follow.
|
768 | */
|
769 | L?: boolean | undefined;
|
770 |
|
771 | /**
|
772 | * Alias for follow.
|
773 | */
|
774 | h?: boolean | undefined;
|
775 |
|
776 | /**
|
777 | * uppress pax extended headers. Note that this means that long paths and
|
778 | * linkpaths will be truncated, and large or negative numeric values
|
779 | * may be interpreted incorrectly.
|
780 | */
|
781 | noPax?: boolean | undefined;
|
782 | }
|
783 |
|
784 | export interface FileOptions {
|
785 | /**
|
786 | * Uses the given file as the input or output of this function.
|
787 | */
|
788 | file?: string | undefined;
|
789 |
|
790 | /**
|
791 | * Alias for file.
|
792 | */
|
793 | f?: string | undefined;
|
794 | }
|
795 |
|
796 | export type RequiredFileOptions = {
|
797 | /**
|
798 | * Uses the given file as the input or output of this function.
|
799 | */
|
800 | file: string;
|
801 | } | {
|
802 | /**
|
803 | * Alias for file.
|
804 | */
|
805 | f: string;
|
806 | };
|
807 |
|
808 | /**
|
809 | * Create a tarball archive. The fileList is an array of paths to add to the
|
810 | * tarball. Adding a directory also adds its children recursively. An entry in
|
811 | * fileList that starts with an @ symbol is a tar archive whose entries will
|
812 | * be added. To add a file that starts with @, prepend it with `./`.
|
813 | *
|
814 | * Archive data may be read from the returned stream.
|
815 | */
|
816 | export function create(
|
817 | options: CreateOptions,
|
818 | fileList: readonly string[],
|
819 | callback?: (err?: Error) => void,
|
820 | ): stream.Readable;
|
821 |
|
822 | /**
|
823 | * Create a tarball archive. The fileList is an array of paths to add to the
|
824 | * tarball. Adding a directory also adds its children recursively. An entry in
|
825 | * fileList that starts with an @ symbol is a tar archive whose entries will
|
826 | * be added. To add a file that starts with @, prepend it with `./`.
|
827 | */
|
828 | export function create(options: CreateOptions & FileOptions, fileList: readonly string[]): Promise<void>;
|
829 | export function create(options: CreateOptions & FileOptions & { sync: true }, fileList: readonly string[]): void;
|
830 | export function create(
|
831 | options: CreateOptions & FileOptions,
|
832 | fileList: readonly string[],
|
833 | callback: (err?: Error) => void,
|
834 | ): void;
|
835 |
|
836 | /**
|
837 | * Alias for create
|
838 | */
|
839 | export const c: typeof create;
|
840 |
|
841 | /**
|
842 | * Extract a tarball archive. The fileList is an array of paths to extract
|
843 | * from the tarball. If no paths are provided, then all the entries are
|
844 | * extracted. If the archive is gzipped, then tar will detect this and unzip
|
845 | * it. Note that all directories that are created will be forced to be
|
846 | * writable, readable, and listable by their owner, to avoid cases where a
|
847 | * directory prevents extraction of child entries by virtue of its mode. Most
|
848 | * extraction errors will cause a warn event to be emitted. If the cwd is
|
849 | * missing, or not a directory, then the extraction will fail completely.
|
850 | *
|
851 | * Archive data should be written to the returned stream.
|
852 | */
|
853 | export function extract(
|
854 | options: ExtractOptions,
|
855 | fileList?: readonly string[],
|
856 | callback?: (err?: Error) => void,
|
857 | ): stream.Writable;
|
858 |
|
859 | /**
|
860 | * Extract a tarball archive. The fileList is an array of paths to extract
|
861 | * from the tarball. If no paths are provided, then all the entries are
|
862 | * extracted. If the archive is gzipped, then tar will detect this and unzip
|
863 | * it. Note that all directories that are created will be forced to be
|
864 | * writable, readable, and listable by their owner, to avoid cases where a
|
865 | * directory prevents extraction of child entries by virtue of its mode. Most
|
866 | * extraction errors will cause a warn event to be emitted. If the cwd is
|
867 | * missing, or not a directory, then the extraction will fail completely.
|
868 | */
|
869 | export function extract(options: ExtractOptions & FileOptions, fileList?: readonly string[]): Promise<void>;
|
870 | export function extract(options: ExtractOptions & FileOptions & { sync: true }, fileList?: readonly string[]): void;
|
871 | export function extract(
|
872 | options: ExtractOptions & FileOptions,
|
873 | fileList: readonly string[] | undefined,
|
874 | callback: (err?: Error) => void,
|
875 | ): void;
|
876 |
|
877 | /**
|
878 | * Alias for extract
|
879 | */
|
880 | export const x: typeof extract;
|
881 |
|
882 | /**
|
883 | * List the contents of a tarball archive. The fileList is an array of paths
|
884 | * to list from the tarball. If no paths are provided, then all the entries
|
885 | * are listed. If the archive is gzipped, then tar will detect this and unzip
|
886 | * it.
|
887 | */
|
888 | export function list(options: ListOptions & RequiredFileOptions, fileList?: readonly string[]): Promise<void>;
|
889 | export function list(
|
890 | options: ListOptions & RequiredFileOptions & { sync: true },
|
891 | fileList?: readonly string[],
|
892 | ): void;
|
893 | export function list(callback?: (err?: Error) => void): Parse;
|
894 | export function list(optionsOrFileList: ListOptions | readonly string[], callback?: (err?: Error) => void): Parse;
|
895 | export function list(options: ListOptions, fileList: readonly string[], callback?: (err?: Error) => void): Parse;
|
896 |
|
897 | /**
|
898 | * Alias for list
|
899 | */
|
900 | export const t: typeof list;
|
901 |
|
902 | /**
|
903 | * Add files to an existing archive. Because later entries override earlier
|
904 | * entries, this effectively replaces any existing entries. The fileList is an
|
905 | * array of paths to add to the tarball. Adding a directory also adds its
|
906 | * children recursively. An entry in fileList that starts with an @ symbol is
|
907 | * a tar archive whose entries will be added. To add a file that
|
908 | * starts with @, prepend it with ./.
|
909 | */
|
910 | export function replace(options: ReplaceOptions, fileList?: readonly string[]): Promise<void>;
|
911 | export function replace(
|
912 | options: ReplaceOptions,
|
913 | fileList: readonly string[] | undefined,
|
914 | callback: (err?: Error) => void,
|
915 | ): Promise<void>;
|
916 |
|
917 | /**
|
918 | * Alias for replace
|
919 | */
|
920 | export const r: typeof replace;
|
921 |
|
922 | /**
|
923 | * Add files to an archive if they are newer than the entry already in the
|
924 | * tarball archive. The fileList is an array of paths to add to the tarball.
|
925 | * Adding a directory also adds its children recursively. An entry in fileList
|
926 | * that starts with an @ symbol is a tar archive whose entries will be added.
|
927 | * To add a file that starts with @, prepend it with ./.
|
928 | */
|
929 | export function update(options: ReplaceOptions, fileList?: readonly string[]): Promise<void>;
|
930 | export function update(
|
931 | options: ReplaceOptions,
|
932 | fileList: readonly string[] | undefined,
|
933 | callback: (err?: Error) => void,
|
934 | ): Promise<void>;
|
935 |
|
936 | /**
|
937 | * Alias for update
|
938 | */
|
939 | export const u: typeof update;
|
940 |
|
941 | export {};
|
942 |
|
\ | No newline at end of file |