UNPKG

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