question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accept `opts.func` for Plugin API

See original GitHub issue

Current: plugin(name, opts, func)

The func parameter should be read as the fallback.

func = opts.func || func

This allows for cleaner plugin (inline & external) definitions; especially if relying on the default every and files settings.

// external
this.plugin('myName', {
  files: true,
  every: false,
  *func(arr) {
    // `arr` is all files
  }
})

// external w/defaults
this.plugin('myName', {
  *func(file) {
    // loop each `file` object
  }
})

// inline w/defaults
exports.fooTask = function * (fly) {
  yield fly.source('foo/*').run({
    *func(file) {
      // loop each `file` object
    }
  }).target('bar')
}

Reference: https://github.com/flyjs/fly/issues/233#issuecomment-274749015

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lukeedcommented, Jan 25, 2017

@jbucaran No problem. So what do you think on the newer suggestion?

It also could mean for simpler external plugins (aka, installed via NPM):

// current
module.exports = function () {
  this.plugin('myName', {every: false}, function * (files, opts) {
    // files: all file objects
    // opts: user options
  });
}

// with proposed change
module.exports = {
  name: 'myName',
  every: false,
  *func(files, opts) {
    // files: all file objects
    // opts: user options
  }
}

cc: @devmondo @hzlmn @watilde

1reaction
lukeedcommented, Jan 24, 2017

Current: plugin(name, opts, func)

this.plugin('nyName', {every: false}, function * (files, opts) {
  // files: all file objects
  // opts: user options
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Options API | Plugin Developer Handbook
The Options API, added in WordPress 1.0, allows creating, reading, updating and deleting of WordPress options. In combination with the…
Read more >
Creating Apollo Server plugins - Apollo GraphQL Docs
To create a plugin that accepts options, create a function that accepts an options object and returns a properly structured plugin object, like...
Read more >
Plugins - Fastify
Creating a plugin is very easy, you just need to create a function that takes three parameters, the fastify instance, an options object,...
Read more >
Falco Plugins Go SDK Walkthrough
The SDK provides options for configuring and overriding all the default values: // sdk/plugins/source func WithInstanceContext(ctx context.
Read more >
terraform-plugin-sdk/serve.go at main - GitHub
Terraform Plugin SDK enables building plugins (providers) to manage any service providers or custom in-house solutions - terraform-plugin-sdk/serve.go at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found