Skip to content

Commit

Permalink
馃 Merge PR #56662 [tar] Add noChmod option to extract by @jnv
Browse files Browse the repository at this point in the history
  • Loading branch information
jnv committed Oct 21, 2021
1 parent 6b3d68b commit a4f1b37
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 10 deletions.
56 changes: 46 additions & 10 deletions types/tar/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for tar 4.0
// Type definitions for tar 6.1
// Project: https://github.com/npm/node-tar
// Definitions by: Maxime LUCE <https://github.com/SomaticIT>, Connor Peet <https://github.com/connor4312>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand Down Expand Up @@ -102,8 +102,8 @@ export const fieldEnds: number[];
*/
export const types: {
0: string;
"\0": string;
"": string;
'\0': string;
'': string;
1: string;
2: string;
3: string;
Expand Down Expand Up @@ -490,6 +490,14 @@ export interface ExtractOptions {
*/
onentry?(entry: ReadEntry): void;

/**
* Set to true to omit calling `fs.chmod()` to ensure that the extracted file
* matches the entry mode. This also suppresses the call to `process.umask()`
* to determine the default umask value, since tar will extract with whatever
* mode is provided, and let the process `umask` apply normally.
*/
noChmod?: boolean | undefined;

// The following options are mostly internal, but can be modified in some
// advanced use cases, such as re-using caches between runs.

Expand Down Expand Up @@ -658,7 +666,11 @@ export interface FileOptions {
*
* Archive data may be read from the returned stream.
*/
export function create(options: CreateOptions, fileList: ReadonlyArray<string>, callback?: (err?: Error) => void): stream.Readable;
export function create(
options: CreateOptions,
fileList: ReadonlyArray<string>,
callback?: (err?: Error) => void,
): stream.Readable;

/**
* Create a tarball archive. The fileList is an array of paths to add to the
Expand All @@ -668,7 +680,11 @@ export function create(options: CreateOptions, fileList: ReadonlyArray<string>,
*/
export function create(options: CreateOptions & FileOptions, fileList: ReadonlyArray<string>): Promise<void>;
export function create(options: CreateOptions & FileOptions & { sync: true }, fileList: ReadonlyArray<string>): void;
export function create(options: CreateOptions & FileOptions, fileList: ReadonlyArray<string>, callback: (err?: Error) => void): void;
export function create(
options: CreateOptions & FileOptions,
fileList: ReadonlyArray<string>,
callback: (err?: Error) => void,
): void;

/**
* Alias for create
Expand All @@ -687,7 +703,11 @@ export const c: typeof create;
*
* Archive data should be written to the returned stream.
*/
export function extract(options: ExtractOptions, fileList?: ReadonlyArray<string>, callback?: (err?: Error) => void): stream.Writable;
export function extract(
options: ExtractOptions,
fileList?: ReadonlyArray<string>,
callback?: (err?: Error) => void,
): stream.Writable;

/**
* Extract a tarball archive. The fileList is an array of paths to extract
Expand All @@ -701,7 +721,11 @@ export function extract(options: ExtractOptions, fileList?: ReadonlyArray<string
*/
export function extract(options: ExtractOptions & FileOptions, fileList?: ReadonlyArray<string>): Promise<void>;
export function extract(options: ExtractOptions & FileOptions & { sync: true }, fileList?: ReadonlyArray<string>): void;
export function extract(options: ExtractOptions & FileOptions, fileList: ReadonlyArray<string> | undefined, callback: (err?: Error) => void): void;
export function extract(
options: ExtractOptions & FileOptions,
fileList: ReadonlyArray<string> | undefined,
callback: (err?: Error) => void,
): void;

/**
* Alias for extract
Expand All @@ -716,7 +740,11 @@ export const x: typeof extract;
*
* Archive data should be written to the returned stream.
*/
export function list(options?: ListOptions & FileOptions, fileList?: ReadonlyArray<string>, callback?: (err?: Error) => void): stream.Writable;
export function list(
options?: ListOptions & FileOptions,
fileList?: ReadonlyArray<string>,
callback?: (err?: Error) => void,
): stream.Writable;

/**
* List the contents of a tarball archive. The fileList is an array of paths
Expand All @@ -741,7 +769,11 @@ export const t: typeof list;
* starts with @, prepend it with ./.
*/
export function replace(options: ReplaceOptions, fileList?: ReadonlyArray<string>): Promise<void>;
export function replace(options: ReplaceOptions, fileList: ReadonlyArray<string> | undefined, callback: (err?: Error) => void): Promise<void>;
export function replace(
options: ReplaceOptions,
fileList: ReadonlyArray<string> | undefined,
callback: (err?: Error) => void,
): Promise<void>;

/**
* Alias for replace
Expand All @@ -756,7 +788,11 @@ export const r: typeof replace;
* To add a file that starts with @, prepend it with ./.
*/
export function update(options: ReplaceOptions, fileList?: ReadonlyArray<string>): Promise<void>;
export function update(options: ReplaceOptions, fileList: ReadonlyArray<string> | undefined, callback: (err?: Error) => void): Promise<void>;
export function update(
options: ReplaceOptions,
fileList: ReadonlyArray<string> | undefined,
callback: (err?: Error) => void,
): Promise<void>;

/**
* Alias for update
Expand Down
1 change: 1 addition & 0 deletions types/tar/tar-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ tar.c(
tar.x(
{
file: 'my-tarball.tgz',
noChmod: true,
}
).then(() => undefined);

Expand Down

0 comments on commit a4f1b37

Please sign in to comment.