mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-21 05:20:24 +08:00
fix(fs-extra): copy can take an async filter function (#24888)
This commit is contained in:
committed by
Mohamed Hegazy
parent
66b655cb71
commit
d22c027901
@@ -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
|
||||
);
|
||||
|
||||
14
types/fs-extra/index.d.ts
vendored
14
types/fs-extra/index.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user