UNPKG

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