UNPKG

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