Sharing Functionalities example not working for `serial` and `parallel` tasks.
- Dominant language
- JavaScript
- Stars
- 203
- Forks
- 31
- PR merge metrics
- No merged PRs in 30d
Description
I tried to use `Sharing Functionalities` from `README` as an example to configure my tasks but it seems to not working, because `this` in function arguments of `series` and `parallel` stay bound to the `Global object`.
There is a `gulpfile.js` to reproduce:
```javascript
var util = require('util');
var gulp = require('gulp');
var DefaultRegistry = require('undertaker-registry');
function ConfigRegistry(config){
DefaultRegistry.call(this);
this.config = config;
}
util.inherits(ConfigRegistry, DefaultRegistry);
ConfigRegistry.prototype.set = function set(name, fn) {
// The `DefaultRegistry` uses `this._tasks` for storage.
var task = this._tasks[name] = fn.bind(this.config);
return task;
};
// `taker.registry` will reset each task in the registry with
// `ConfigRegistry.prototype.set` which will bind them to the config object.
gulp.registry(new ConfigRegistry({
config: {
src: './src',
build: './build',
bindTo: '0.0.0.0:8888'
}
}));
gulp.task('dummy', function(cb) {
// OK
console.log('Config: ' + JSON.stringify(this.config));
cb();
})
gulp.task('test-series', gulp.series('dummy', function(cb) {
// undefined
console.log('Config: ' + JSON.stringify(this.config));
cb();
}));
gulp.task('test-parallel', gulp.parallel('dummy', function(cb) {
// undefined
console.log('Config: ' + JSON.stringify(this.config));
cb();
}))
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.