jackfranklin / gulp-load-plugins

Automatically load in gulp plugins
https://github.com/jackfranklin/gulp-load-plugins
MIT License
757 stars 55 forks source link

Automatically add plugins to scope? #28

Closed ghost closed 10 years ago

ghost commented 10 years ago

This plugin is great.. but is there a way to import gulp modules without then having me to use the plugins var?

The grunt alternative automagically does that!

Ideally, I'd want to call clean() instead of plugins.clean()

Is this possible?

jackfranklin commented 10 years ago

Hey @tUrG0n,

This used to be how it worked - but I then had feedback saying it would be preferred to add tasks to a variable instead. I guess there's no reason why you couldn't call the plugin and pass in this, maybe like:

require('gulp-load-plugins')({
  attachToScope: this
});

How would that sound?

I don't think I would ever make that default behaviour (I personally enjoy the explicit nature of var plugins = ...) but I wouldn't be against adding something akin to the above.

jackfranklin commented 10 years ago

So the above approach doesn't work, because the scope used inside a gulp.task block is different to that used outside of one. I'm open to suggestions on this but I'm not sure if it's going to be possible.

sindresorhus commented 10 years ago

No. This should never be supported. Introducing implicit globals is an awful practise. Please close.

jackfranklin commented 10 years ago

Agree - along with the fact that there's no really good solution to how to implement it - I prefer the explicit approach, which most users of this plugin seem to do too (it used to be done implicitly but changed on the basis of feedback), so this won't be being implemented.