lukeed / taskr

A fast, concurrency-focused task automation tool.
MIT License
2.53k stars 74 forks source link

Plugins: Pass ALL arguments to function #224

Closed lukeed closed 7 years ago

lukeed commented 7 years ago

In older versions of Fly, custom plugins were able to accept/handle more than a single opts object.

While restricting plugin authors to opts only is great for uniformity, it's sometimes more trouble than it's worth, based on the underlying/wrapped API.

So, a single opts object should be strongly recommended for ease-of-use & approachability, but Fly should (continue to) pass extra values when absolutely necessary.

// current
this.plugin('name', {}, function * (file, opts) {
  console.log('everything is in "opts"');
});

// flyfile
yield this.source('*').name({hello: 'world'}).target('dist');
// proposed
this.plugin('name', {}, function * (file, str, opts) {
  console.log('this is my greeting: ', str);
  console.log('this is my audience: ', opts.who);
});

// flyfile
yield this.source('*').name('hello', {who: 'world'}).target('dist');