Skip to content

Commit c691572

Browse files
Contraphated
authored andcommitted
Update: Bind all undertaker functions on the gulp instance to allow destructuring
1 parent 468a703 commit c691572

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ var chokidar = require('chokidar');
77

88
function Gulp() {
99
Undertaker.call(this);
10+
11+
// Bind the functions for destructuring
12+
this.watch = this.watch.bind(this);
13+
this.task = this.task.bind(this);
14+
this.series = this.series.bind(this);
15+
this.parallel = this.parallel.bind(this);
16+
this.registry = this.registry.bind(this);
17+
this.tree = this.tree.bind(this);
18+
this.lastRun = this.lastRun.bind(this);
1019
}
1120
util.inherits(Gulp, Undertaker);
1221

test/watch.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,23 @@ describe('gulp', function() {
6060
updateTempFile(tempFile);
6161
});
6262

63+
it('should work with destructuring', function(done) {
64+
var tempFile = path.join(outpath, 'watch-func.txt');
65+
var watch = gulp.watch;
66+
var parallel = gulp.parallel;
67+
var task = gulp.task;
68+
createTempFile(tempFile);
69+
70+
task('test', function(cb) {
71+
watcher.close();
72+
cb();
73+
done();
74+
});
75+
76+
var watcher = watch(tempFile, parallel('test'));
77+
78+
updateTempFile(tempFile);
79+
});
6380

6481
it('should not call the function when no file changes: no options', function(done) {
6582
var tempFile = path.join(outpath, 'watch-func.txt');

0 commit comments

Comments
 (0)