Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tar] Add noChmod option to extract #56662

Merged
merged 1 commit into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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