-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
index.js
32 lines (26 loc) · 737 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict';
var getHook = require('./lib/get-hook');
module.exports = function (gulp) {
return {
stream: function (name, options) {
var hook = getHook(name);
if (!hook.stream) {
throw new Error('Hook not streamable: ' + name);
}
return hook.stream(gulp, options);
},
src: function (name, fn) {
var hook = getHook(name);
if (fn && typeof fn === 'function') {
if (hook.extra) {
return fn.bind(fn, hook.src, hook.extra);
} else {
return fn.bind(fn, hook.src);
}
} else if (!hook.src) {
throw new Error('Hook has no source files, use guppy.src() as a callback: ' + name);
}
return hook.src;
}
};
};