fix(fs-extra): copy can take an async filter function (#24888)

This commit is contained in:
Justin Rockwood
2018-04-11 11:59:19 -07:00
committed by Mohamed Hegazy
parent 66b655cb71
commit d22c027901
2 changed files with 11 additions and 5 deletions

View File

@@ -48,7 +48,7 @@ fs.copy(src, dest,
{
overwrite: true,
preserveTimestamps: true,
filter: (src: string, dest: string) => false
filter: (src: string, dest: string) => Promise.resolve(false)
},
errorCallback
);

View File

@@ -3,7 +3,8 @@
// Definitions by: Alan Agius <https://github.com/alan-agius4>,
// midknight41 <https://github.com/midknight41>,
// Brendan Forster <https://github.com/shiftkey>,
// Mees van Dijk <https://github.com/mees->
// Mees van Dijk <https://github.com/mees->,
// Justin Rockwood <https://github.com/jrockwood>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -16,7 +17,7 @@ export * from "fs";
export function copy(src: string, dest: string, options?: CopyOptions): Promise<void>;
export function copy(src: string, dest: string, callback: (err: Error) => void): void;
export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error) => void): void;
export function copySync(src: string, dest: string, options?: CopyOptions): void;
export function copySync(src: string, dest: string, options?: CopyOptionsSync): void;
export function move(src: string, dest: string, options?: MoveOptions): Promise<void>;
export function move(src: string, dest: string, callback: (err: Error) => void): void;
@@ -254,7 +255,8 @@ export interface PathEntryStream {
read(): PathEntry | null;
}
export type CopyFilter = (src: string, dest: string) => boolean;
export type CopyFilterSync = (src: string, dest: string) => boolean;
export type CopyFilterAsync = (src: string, dest: string) => Promise<boolean>;
export type SymlinkType = "dir" | "file";
@@ -263,10 +265,14 @@ export interface CopyOptions {
overwrite?: boolean;
preserveTimestamps?: boolean;
errorOnExist?: boolean;
filter?: CopyFilter;
filter?: CopyFilterSync | CopyFilterAsync;
recursive?: boolean;
}
export interface CopyOptionsSync extends CopyOptions {
filter?: CopyFilterSync;
}
export interface MoveOptions {
overwrite?: boolean;
limit?: number;