Updates tar-fs to include pack option (#42813)

* Updates tar-fs to include pack option

* Switch away from require

* Remove explicit typescript version
This commit is contained in:
Chris Wiggins 2020-03-15 15:04:58 +13:00 committed by GitHub
parent 5ed9dc7696
commit cbeb5ba463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -1,15 +1,15 @@
// Type definitions for tar-fs 1.16
// Project: https://github.com/mafintosh/tar-fs
// Definitions by: Umoxfo <https://github.com/Umoxfo>
// Chris Wiggins <https://github.com/chriswiggins>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts
/// <reference types="node" />
import fs = require('fs');
import tarStream = require('tar-stream');
import { ReadStream } from 'fs';
import * as tarStream from 'tar-stream';
export function pack(cwd: string, opts?: PackOptions): tarStream.Pack;
export function extract(cwd: string, opts?: ExtractOptions): tarStream.Extract;
@ -21,7 +21,7 @@ export interface Options {
ignore?: (name: string) => boolean;
filter?: (name: string) => boolean;
map?: (header: Headers) => Headers;
mapStream?: (fileStream: fs.ReadStream, header: Headers) => fs.ReadStream;
mapStream?: (fileStream: ReadStream, header: Headers) => ReadStream;
dmode?: number;
fmode?: number;
readable?: boolean;
@ -33,7 +33,8 @@ export interface PackOptions extends Options {
entries?: string[];
dereference?: boolean;
finalize?: boolean;
finish?: (pack: any) => void;
finish?: (pack: tarStream.Pack) => void;
pack?: tarStream.Pack;
}
export interface ExtractOptions extends Options {

View File

@ -101,3 +101,15 @@ tar.pack('./my-directory', {
*/
tar.pack('./my-directory').entry({ name: 'generated-file.txt' }, '1234');
tar.pack('./my-directory').finalize();
/**
* Interact with tar-stream and do multiple packs
*/
tar.pack('./my-directory', {
finalize: false,
finish: (parentPack) => {
tar.pack('./other-directory', {
pack: parentPack
});
}
});