1 |
|
2 |
|
3 |
|
4 |
|
5 | import Orchestrator = require("orchestrator");
|
6 | import VinylFile = require("vinyl");
|
7 |
|
8 | declare namespace gulp {
|
9 | interface Gulp extends Orchestrator {
|
10 | task(name: string): never;
|
11 | |
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | task(name: string, fn?: Orchestrator.TaskFunc): Gulp;
|
22 | |
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | task(name: string, deps?: string[], fn?: Orchestrator.TaskFunc): Gulp;
|
33 |
|
34 | |
35 |
|
36 |
|
37 |
|
38 |
|
39 | src: SrcMethod;
|
40 | |
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | dest: DestMethod;
|
48 | |
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 | watch: WatchMethod;
|
56 | }
|
57 |
|
58 | interface GulpPlugin {
|
59 | (...args: any[]): NodeJS.ReadWriteStream;
|
60 | }
|
61 |
|
62 | interface WatchMethod {
|
63 | |
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | (glob: string | string[], fn: WatchCallback | string): NodeJS.EventEmitter;
|
70 | |
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 | (glob: string | string[], fn: (WatchCallback | string)[]): NodeJS.EventEmitter;
|
77 | |
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 | (glob: string | string[], opt: WatchOptions, fn: WatchCallback | string): NodeJS.EventEmitter;
|
85 | |
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 | (glob: string | string[], opt: WatchOptions, fn: (WatchCallback | string)[]): NodeJS.EventEmitter;
|
93 | }
|
94 |
|
95 | interface DestMethod {
|
96 | |
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 |
|
103 | (outFolder: string | ((file: VinylFile) => string), opt?: DestOptions): NodeJS.ReadWriteStream;
|
104 | }
|
105 |
|
106 | interface SrcMethod {
|
107 | /**
|
108 | * Emits files matching provided glob or an array of globs. Returns a stream of Vinyl files that can be piped to plugins.
|
109 | * @param glob Glob or array of globs to read.
|
110 | * @param opt Options to pass to node-glob through glob-stream.
|
111 | */
|
112 | (glob: string | string[], opt?: SrcOptions): NodeJS.ReadWriteStream;
|
113 | }
|
114 |
|
115 | /**
|
116 | * Options to pass to node-glob through glob-stream.
|
117 | * Specifies two options in addition to those used by node-glob:
|
118 | * https://github.com/isaacs/node-glob#options
|
119 | */
|
120 | interface SrcOptions {
|
121 | /**
|
122 | * Setting this to <code>false</code> will return <code>file.contents</code> as <code>null</code>
|
123 | * and not read the file at all.
|
124 | * Default: <code>true</code>.
|
125 | */
|
126 | read?: boolean | undefined;
|
127 |
|
128 | /**
|
129 | * Setting this to false will return <code>file.contents</code> as a stream and not buffer files.
|
130 | * This is useful when working with large files.
|
131 | * Note: Plugins might not implement support for streams.
|
132 | * Default: <code>true</code>.
|
133 | */
|
134 | buffer?: boolean | undefined;
|
135 |
|
136 | /**
|
137 | * The base path of a glob.
|
138 | *
|
139 | * Default is everything before a glob starts.
|
140 | */
|
141 | base?: string | undefined;
|
142 |
|
143 | /**
|
144 | * The current working directory in which to search.
|
145 | * Defaults to process.cwd().
|
146 | */
|
147 | cwd?: string | undefined;
|
148 |
|
149 | /**
|
150 | * The place where patterns starting with / will be mounted onto.
|
151 | * Defaults to path.resolve(options.cwd, "/") (/ on Unix systems, and C:\ or some such on Windows.)
|
152 | */
|
153 | root?: string | undefined;
|
154 |
|
155 | /**
|
156 | * Include .dot files in normal matches and globstar matches.
|
157 | * Note that an explicit dot in a portion of the pattern will always match dot files.
|
158 | */
|
159 | dot?: boolean | undefined;
|
160 |
|
161 | /**
|
162 | * Set to match only fles, not directories. Set this flag to prevent copying empty directories
|
163 | */
|
164 | nodir?: boolean | undefined;
|
165 |
|
166 | /**
|
167 | * By default, a pattern starting with a forward-slash will be "mounted" onto the root setting, so that a valid
|
168 | * filesystem path is returned. Set this flag to disable that behavior.
|
169 | */
|
170 | nomount?: boolean | undefined;
|
171 |
|
172 | /**
|
173 | * Add a / character to directory matches. Note that this requires additional stat calls.
|
174 | */
|
175 | mark?: boolean | undefined;
|
176 |
|
177 | /**
|
178 | * Don't sort the results.
|
179 | */
|
180 | nosort?: boolean | undefined;
|
181 |
|
182 | /**
|
183 | * Set to true to stat all results. This reduces performance somewhat, and is completely unnecessary, unless
|
184 | * readdir is presumed to be an untrustworthy indicator of file existence. It will cause ELOOP to be triggered one
|
185 | * level sooner in the case of cyclical symbolic links.
|
186 | */
|
187 | stat?: boolean | undefined;
|
188 |
|
189 | /**
|
190 | * When an unusual error is encountered when attempting to read a directory, a warning will be printed to stderr.
|
191 | * Set the silent option to true to suppress these warnings.
|
192 | */
|
193 | silent?: boolean | undefined;
|
194 |
|
195 | /**
|
196 | * When an unusual error is encountered when attempting to read a directory, the process will just continue on in
|
197 | * search of other matches. Set the strict option to raise an error in these cases.
|
198 | */
|
199 | strict?: boolean | undefined;
|
200 |
|
201 | /**
|
202 | * See cache property above. Pass in a previously generated cache object to save some fs calls.
|
203 | */
|
204 | cache?: boolean | undefined;
|
205 |
|
206 | /**
|
207 | * A cache of results of filesystem information, to prevent unnecessary stat calls.
|
208 | * While it should not normally be necessary to set this, you may pass the statCache from one glob() call to the
|
209 | * options object of another, if you know that the filesystem will not change between calls.
|
210 | */
|
211 | statCache?: boolean | undefined;
|
212 |
|
213 | /**
|
214 | * Perform a synchronous glob search.
|
215 | */
|
216 | sync?: boolean | undefined;
|
217 |
|
218 | /**
|
219 | * In some cases, brace-expanded patterns can result in the same file showing up multiple times in the result set.
|
220 | * By default, this implementation prevents duplicates in the result set. Set this flag to disable that behavior.
|
221 | */
|
222 | nounique?: boolean | undefined;
|
223 |
|
224 | /**
|
225 | * Set to never return an empty set, instead returning a set containing the pattern itself.
|
226 | * This is the default in glob(3).
|
227 | */
|
228 | nonull?: boolean | undefined;
|
229 |
|
230 | /**
|
231 | * Perform a case-insensitive match. Note that case-insensitive filesystems will sometimes result in glob returning
|
232 | * results that are case-insensitively matched anyway, since readdir and stat will not raise an error.
|
233 | */
|
234 | nocase?: boolean | undefined;
|
235 |
|
236 | /**
|
237 | * Set to enable debug logging in minimatch and glob.
|
238 | */
|
239 | debug?: boolean | undefined;
|
240 |
|
241 | /**
|
242 | * Set to enable debug logging in glob, but not minimatch.
|
243 | */
|
244 | globDebug?: boolean | undefined;
|
245 | }
|
246 |
|
247 | interface DestOptions {
|
248 | /**
|
249 | * The output folder. Only has an effect if provided output folder is relative.
|
250 | * Default: process.cwd()
|
251 | */
|
252 | cwd?: string | undefined;
|
253 |
|
254 | /**
|
255 | * Octal permission string specifying mode for any folders that need to be created for output folder.
|
256 | * Default: 0777.
|
257 | */
|
258 | mode?: string | undefined;
|
259 | }
|
260 |
|
261 | /**
|
262 | * Options that are passed to <code>gaze</code>.
|
263 | * https://github.com/shama/gaze
|
264 | */
|
265 | interface WatchOptions {
|
266 | /** Interval to pass to fs.watchFile. */
|
267 | interval?: number | undefined;
|
268 | /** Delay for events called in succession for the same file/event. */
|
269 | debounceDelay?: number | undefined;
|
270 | /** Force the watch mode. Either 'auto' (default), 'watch' (force native events), or 'poll' (force stat polling). */
|
271 | mode?: string | undefined;
|
272 | /** The current working directory to base file patterns from. Default is process.cwd().. */
|
273 | cwd?: string | undefined;
|
274 | }
|
275 |
|
276 | interface WatchEvent {
|
277 | /** The type of change that occurred, either added, changed or deleted. */
|
278 | type: string;
|
279 | /** The path to the file that triggered the event. */
|
280 | path: string;
|
281 | }
|
282 |
|
283 | /**
|
284 | * Callback to be called on each watched file change.
|
285 | */
|
286 | interface WatchCallback {
|
287 | (event: WatchEvent): void;
|
288 | }
|
289 |
|
290 | interface TaskCallback {
|
291 | /**
|
292 | * Defines a task.
|
293 | * Tasks may be made asynchronous if they are passing a callback or return a promise or a stream.
|
294 | * @param cb callback used to signal asynchronous completion. Caller includes <code>err</code> in case of error.
|
295 | */
|
296 | (cb?: (err?: any) => void): any;
|
297 | }
|
298 | }
|
299 |
|
300 | declare var gulp: gulp.Gulp;
|
301 |
|
302 | export = gulp;
|
303 |
|
\ | No newline at end of file |