UNPKG

3.05 kBTypeScriptView Raw
1// Type definitions for gulp-if
2// Project: https://github.com/robrich/gulp-if
3// Definitions by: Asana <https://asana.com>, Joe Skeen <https://github.com/joeskeen>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/// <reference types="node"/>
7/// <reference types="vinyl" />
8
9import fs = require('fs');
10import vinyl = require('vinyl');
11
12interface GulpIf {
13 /**
14 * gulp-if will pipe data to stream whenever condition is truthy.
15 * If condition is falsey and elseStream is passed, data will pipe to elseStream
16 * After data is piped to stream or elseStream or neither, data is piped down-stream.
17 *
18 * @param condition whether input should be piped to stream
19 * @param stream the stream to pipe to if condition is true
20 * @param elseStream (optional) the stream to pipe to if condition is false
21 */
22 (condition: boolean, stream: NodeJS.ReadWriteStream, elseStream?: NodeJS.ReadWriteStream): NodeJS.ReadWriteStream;
23 /**
24 * gulp-if will pipe data to stream whenever condition is truthy.
25 * If condition is falsey and elseStream is passed, data will pipe to elseStream
26 * After data is piped to stream or elseStream or neither, data is piped down-stream.
27 *
28 * @param condition a Node Stat filter condition to be executed on the vinyl file's Stats object
29 * @param stream the stream to pipe to if condition is true
30 * @param elseStream (optional) the stream to pipe to if condition is false
31 */
32 (condition: StatFilterCondition, stream: NodeJS.ReadWriteStream, elseStream?: NodeJS.ReadWriteStream): NodeJS.ReadWriteStream;
33 /**
34 * gulp-if will pipe data to stream whenever condition is truthy.
35 * If condition is falsey and elseStream is passed, data will pipe to elseStream
36 * After data is piped to stream or elseStream or neither, data is piped down-stream.
37 *
38 * @param condition a function taking a vinyl file and returning a boolean
39 * @param stream the stream to pipe to if condition is true
40 * @param elseStream (optional) the stream to pipe to if condition is false
41 */
42 (condition: (fs: vinyl) => boolean, stream: NodeJS.ReadWriteStream, elseStream?: NodeJS.ReadWriteStream): NodeJS.ReadWriteStream;
43 /**
44 * gulp-if will pipe data to stream whenever condition is truthy.
45 * If condition is falsey and elseStream is passed, data will pipe to elseStream
46 * After data is piped to stream or elseStream or neither, data is piped down-stream.
47 *
48 * @param condition a RegularExpression that works on the file.path
49 * @param stream the stream to pipe to if condition is true
50 * @param elseStream (optional) the stream to pipe to if condition is false
51 */
52 (condition: RegExp, stream: NodeJS.ReadWriteStream, elseStream?: NodeJS.ReadWriteStream): NodeJS.ReadWriteStream;
53}
54
55interface StatFilterCondition {
56 isDirectory?: boolean;
57 isFile?: boolean;
58}
59
60declare var gulpIf: GulpIf;
61
62export = gulpIf;