UNPKG

3.25 kBTypeScriptView Raw
1// Type definitions for Gulp 4.0
2// Project: http://gulpjs.com
3// Definitions by: Drew Noakes <https://drewnoakes.com>
4// Juan Arroyave <http://jarroyave.co>
5// Giedrius Grabauskas <https://github.com/GiedriusGrabauskas>
6// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
7
8import * as vfs from "vinyl-fs";
9import * as chokidar from "chokidar";
10import * as Undertaker from "undertaker";
11import * as fs from "fs";
12import { Duplex } from "stream";
13
14declare namespace GulpClient {
15 type Globs = string | string[];
16
17 type TaskFunction = Undertaker.TaskFunction;
18
19 /**
20 * @deprecated - Now use `TaskFunction`.
21 */
22 type TaskCallback = TaskFunction;
23
24 type TaskFunctionCallback = Undertaker.TaskCallback;
25
26 interface Gulp extends Undertaker {
27 /**
28 * Emits files matching provided glob or array of globs. Returns a stream of Vinyl files that can be piped to plugins.
29 * @param globs Glob or array of globs to read.
30 * @param options Options to pass to node-glob through glob-stream.
31 */
32 src: SrcMethod;
33
34 /**
35 * Can be piped to and it will write files. Re-emits all data passed to it so you can pipe to multiple folders.
36 * Folders that don't exist will be created.
37 * @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.
38 */
39 dest: DestMethod;
40
41 /**
42 * Functions exactly like gulp.dest, but will create symlinks instead of copying a directory.
43 * @param folder A folder path or a function that receives in a file and returns a folder path.
44 */
45 symlink: typeof vfs.symlink;
46
47 /**
48 * 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.
49 * Also optionally takes options to configure the watcher and a fn to execute when a file changes.
50 * @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.
51 * @opts Options that are passed to chokidar.
52 * @fn Once async completion is signalled, if another run is queued, it will be executed.
53 */
54 watch: WatchMethod;
55 }
56
57 interface WatchOptions extends chokidar.WatchOptions {
58 /**
59 * The delay to wait before triggering the fn.
60 * Useful for waiting on many changes before doing the work on changed files, e.g. find-and-replace on many files.
61 * @default 200
62 */
63 delay?: number | undefined;
64 /**
65 * Whether or not a file change should queue the fn execution if the fn is already running. Useful for a long running fn.
66 * @default true
67 */
68 queue?: boolean | undefined;
69 }
70
71 interface WatchMethod {
72 (globs: Globs, fn?: Undertaker.TaskFunction): fs.FSWatcher;
73 (globs: Globs, opts?: WatchOptions, fn?: Undertaker.TaskFunction): fs.FSWatcher;
74 }
75
76 type SrcMethod = typeof vfs.src;
77
78 type DestMethod = typeof vfs.dest;
79}
80
81declare const GulpClient: GulpClient.Gulp;
82export = GulpClient;