Skip to content

Commit

Permalink
Update: Bind all undertaker functions on the gulp instance to allow d…
Browse files Browse the repository at this point in the history
…estructuring
  • Loading branch information
Contra authored and phated committed Dec 31, 2017
1 parent 468a703 commit c691572
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ var chokidar = require('chokidar');

function Gulp() {
Undertaker.call(this);

// Bind the functions for destructuring
this.watch = this.watch.bind(this);
this.task = this.task.bind(this);
this.series = this.series.bind(this);
this.parallel = this.parallel.bind(this);
this.registry = this.registry.bind(this);
this.tree = this.tree.bind(this);
this.lastRun = this.lastRun.bind(this);
}
util.inherits(Gulp, Undertaker);

Expand Down
17 changes: 17 additions & 0 deletions test/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,23 @@ describe('gulp', function() {
updateTempFile(tempFile);
});

it('should work with destructuring', function(done) {
var tempFile = path.join(outpath, 'watch-func.txt');
var watch = gulp.watch;
var parallel = gulp.parallel;
var task = gulp.task;
createTempFile(tempFile);

task('test', function(cb) {
watcher.close();
cb();
done();
});

var watcher = watch(tempFile, parallel('test'));

updateTempFile(tempFile);
});

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

0 comments on commit c691572

Please sign in to comment.