UNPKG

2.64 kBTypeScriptView Raw
1import { Stats } from "fs-extra";
2export declare const MAX_FILE_REQUESTS = 8;
3export declare const CONCURRENCY: {
4 concurrency: number;
5};
6export declare type AfterCopyFileTransformer = (file: string) => Promise<void>;
7export declare class CopyFileTransformer {
8 readonly afterCopyTransformer: AfterCopyFileTransformer;
9 constructor(afterCopyTransformer: AfterCopyFileTransformer);
10}
11export declare type FileTransformer = (file: string) => Promise<null | string | Buffer | CopyFileTransformer> | null | string | Buffer | CopyFileTransformer;
12export declare type Filter = (file: string, stat: Stats) => boolean;
13export declare function unlinkIfExists(file: string): Promise<void>;
14export declare function statOrNull(file: string): Promise<Stats | null>;
15export declare function exists(file: string): Promise<boolean>;
16export interface FileConsumer {
17 consume(file: string, fileStat: Stats, parent: string, siblingNames: Array<string>): any;
18 /**
19 * @default false
20 */
21 isIncludeDir?: boolean;
22}
23/**
24 * Returns list of file paths (system-dependent file separator)
25 */
26export declare function walk(initialDirPath: string, filter?: Filter | null, consumer?: FileConsumer): Promise<Array<string>>;
27export declare function copyFile(src: string, dest: string, isEnsureDir?: boolean): Promise<any>;
28/**
29 * Hard links is used if supported and allowed.
30 * File permission is fixed — allow execute for all if owner can, allow read for all if owner can.
31 *
32 * ensureDir is not called, dest parent dir must exists
33 */
34export declare function copyOrLinkFile(src: string, dest: string, stats?: Stats | null, isUseHardLink?: boolean, exDevErrorHandler?: (() => boolean) | null): Promise<any>;
35export declare class FileCopier {
36 private readonly isUseHardLinkFunction?;
37 private readonly transformer?;
38 isUseHardLink: boolean;
39 constructor(isUseHardLinkFunction?: ((file: string) => boolean) | null | undefined, transformer?: FileTransformer | null | undefined);
40 copy(src: string, dest: string, stat: Stats | undefined): Promise<void>;
41}
42export interface CopyDirOptions {
43 filter?: Filter | null;
44 transformer?: FileTransformer | null;
45 isUseHardLink?: ((file: string) => boolean) | null;
46}
47/**
48 * Empty directories is never created.
49 * Hard links is used if supported and allowed.
50 */
51export declare function copyDir(src: string, destination: string, options?: CopyDirOptions): Promise<any>;
52export declare const DO_NOT_USE_HARD_LINKS: (file: string) => boolean;
53export declare const USE_HARD_LINKS: (file: string) => boolean;
54export interface Link {
55 readonly link: string;
56 readonly file: string;
57}