UNPKG

1.55 kBTypeScriptView Raw
1/// <reference types="node" />
2
3import { EventEmitter } from "events";
4import * as stream from "stream";
5
6export interface SyncOptions {
7 /** remove files that copied on past before copy. */
8 clean?: boolean | undefined;
9 /** Follow symbolic links when copying from them. */
10 dereference?: boolean | undefined;
11 /** Copy empty directories which is matched with the glob. */
12 includeEmptyDirs?: boolean | undefined;
13 /** Preserve UID, GID, ATIME, and MTIME of files. */
14 preserve?: boolean | undefined;
15 /** Do not overwrite files on destination if the source file is older. */
16 update?: boolean | undefined;
17}
18
19export interface AsyncOptions extends SyncOptions {
20 /** Function that creates a `stream.Transform` object to transform each copying file. */
21 transform?(filepath: string): stream.Transform[];
22}
23
24export interface WatchOptions extends AsyncOptions, SyncOptions {
25 /** Flag to not copy at the initial time of watch. */
26 initialCopy?: boolean | undefined;
27}
28
29export class Watcher extends EventEmitter {
30 constructor(options: WatchOptions);
31 open(): void;
32 close(): void;
33}
34
35export function copy(
36 source: string,
37 dest: string,
38 options?: AsyncOptions,
39 callback?: (error: Error | null) => void,
40): void;
41export function copy(source: string, dest: string, callback?: (error: Error | null) => void): void;
42
43export function copySync(source: string, dest: string, options?: SyncOptions): void;
44
45export function watch(source: string, dest: string, options?: WatchOptions): Watcher;