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