UNPKG

3.56 kBTypeScriptView Raw
1import * as chokidar from "chokidar";
2import * as fs from "fs";
3import { Duplex } from "stream";
4import * as Undertaker from "undertaker";
5import * as vfs from "vinyl-fs";
6
7declare namespace GulpClient {
8 type Globs = string | string[];
9
10 type TaskFunction = Undertaker.TaskFunction;
11
12 /**
13 * @deprecated - Now use `TaskFunction`.
14 */
15 type TaskCallback = TaskFunction;
16
17 type TaskFunctionCallback = Undertaker.TaskCallback;
18
19 interface Gulp extends Undertaker {
20 /**
21 * Emits files matching provided glob or array of globs. Returns a stream of Vinyl files that can be piped to plugins.
22 * @param globs Glob or array of globs to read.
23 * @param options Options to pass to node-glob through glob-stream.
24 */
25 src: SrcMethod;
26
27 /**
28 * Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders.
29 * Folders that don't exist will be created.
30 * @param path The path (output folder) to write files to. Or a function that returns it, the function will be provided a vinyl File instance.
31 */
32 dest: DestMethod;
33
34 /**
35 * Functions exactly like gulp.dest, but will create symlinks instead of copying a directory.
36 * @param folder A folder path or a function that receives in a file and returns a folder path.
37 */
38 symlink: typeof vfs.symlink;
39
40 /**
41 * Takes a path string, an array of path strings, a glob string or an array of glob strings as globs to watch on the filesystem.
42 * Also optionally takes options to configure the watcher and a fn to execute when a file changes.
43 * @param globs A path string, an array of path strings, a glob string or an array of glob strings that indicate which files to watch for changes.
44 * @param opts Options that are passed to chokidar.
45 * @param fn Once async completion is signalled, if another run is queued, it will be executed.
46 */
47 watch: WatchMethod;
48 }
49
50 interface WatchOptions extends chokidar.WatchOptions {
51 /**
52 * The delay to wait before triggering the fn.
53 * Useful for waiting on many changes before doing the work on changed files, e.g. find-and-replace on many files.
54 * @default 200
55 */
56 delay?: number | undefined;
57 /**
58 * Whether or not a file change should queue the fn execution if the fn is already running. Useful for a long running fn.
59 * @default true
60 */
61 queue?: boolean | undefined;
62 /**
63 * An event name or array of event names to listen for. Useful if you only need to watch specific events.
64 * @example
65 * gulp.watch is imported from glob-watcher (see https://github.com/gulpjs/gulp/blob/v4.0.2/index.js lines 6, 28 and 48)
66 * gulp use glob-watcher@^5.0.3 (see https://github.com/gulpjs/gulp/blob/v4.0.2/package.json#L33)
67 * glob-watcher declare publicly options.events (see https://github.com/gulpjs/glob-watcher/blob/v5.0.3/README.md?plain=1#L101)
68 * @default ['add','change','unlink']
69 */
70 events?: string | string[];
71 }
72
73 interface WatchMethod {
74 (globs: Globs, fn?: Undertaker.TaskFunction): fs.FSWatcher;
75 (globs: Globs, opts?: WatchOptions, fn?: Undertaker.TaskFunction): fs.FSWatcher;
76 }
77
78 type SrcMethod = typeof vfs.src;
79
80 type DestMethod = typeof vfs.dest;
81}
82
83declare const GulpClient: GulpClient.Gulp;
84export = GulpClient;