jackfranklin / gulp-load-plugins

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

loading plugins changes scope of their path #117

Closed mrt123 closed 5 years ago

mrt123 commented 8 years ago

Issue found when working with node_module : "require-dir": "0.3.0",

var gulp = require('gulp'), requireDir = require('require-dir');

requireDir('./gulp-tasks', { recurse: true } );  // will look for directories in ./gulp-tasks

however

var gulpLoadPlugins = require('gulp-load-plugins');
var plugs = gulpLoadPlugins({
    pattern: ['*', '!gulp'],
    scope: ['devDependencies']
});
plugs.requireDir('./gulp-tasks', { recurse: true } );
// tries to require directories from /node_modules/gulp-load-plugins/gulp-tasks'
jackfranklin commented 8 years ago

Can you try passing requireFn: require and see if that fixes it?

Else you could do path.join(__dirname, 'gulp-tasks') to give an absolute path. I'm not sure if there's a way to prevent the scope changing here.

jackfranklin commented 8 years ago

Could be something to do with https://github.com/jackfranklin/gulp-load-plugins/blob/master/index.js#L62

jackfranklin commented 8 years ago

@mrt123 is this still an issue? Did you ever find a way round it?

jameelmoses commented 5 years ago

Closing due to inactivity