jackfranklin / gulp-load-plugins

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

Error not thrown if module not installed #42

Closed Graham42 closed 10 years ago

Graham42 commented 10 years ago

Can you make it an option to throw an erorr if a module is not installed?

Normally var xy = require('xy') Would throw Error: Cannot find module 'xy' if xy is not installed

But if I do

var $ = require('gulp-load-plugins')({
    pattern: ['gulp-*', 'xy'],
});

No error is thrown

jackfranklin commented 10 years ago

@Graham42 I would expect that to throw if you then referenced $.xy - this is because plugins are lazily loaded.

That said, I wouldn't recommend using gulp-load-plugins for loading all your plugins in anyway, that's not what it's designed for.

Graham42 commented 10 years ago

In that case it's probably working as intended. Feel free to close this if it's only meant to work with modules like gulp-*.

I confirmed it works for gulp plugins but not for others. For example for module fs I get this stacktrack and nothing about not finding a module.

TypeError: Object #<Object> has no method 'readdirSync'
    at getFolders ( <my_project_directory> /gulp/build.js:16:15)
    at Gulp.buildParts ( <my_project_directory> /gulp/build.js:39:16)
    at module.exports ( <my_project_directory> /node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask ( <my_project_directory> /node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep ( <my_project_directory> /node_modules/gulp/node_modules/orchestrator/index.js:214:10)
    at Gulp.Orchestrator.start ( <my_project_directory> /node_modules/gulp/node_modules/orchestrator/index.js:134:8)
    at Gulp.<anonymous> ( <my_project_directory> /gulp/build.js:61:7)
    at module.exports ( <my_project_directory> /node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7)
    at Gulp.Orchestrator._runTask ( <my_project_directory> /node_modules/gulp/node_modules/orchestrator/index.js:273:3)
    at Gulp.Orchestrator._runStep ( <my_project_directory> /node_modules/gulp/node_modules/orchestrator/index.js:214:10)
jackfranklin commented 10 years ago

@Graham42 it is only expected to work with gulp plugins but it seems odd that it would break for others. Can you show me the code that's generating that error?

Graham42 commented 10 years ago

Was having a really hard time reproducing and then realized I had a typo. Sorry! The issue was actually between the keyboard and the chair.