defunctzombie / node-required

identifies which modules your script is using
67 stars 15 forks source link

error handler function? #11

Closed DTrejo closed 10 years ago

DTrejo commented 10 years ago

Hey man,

It would be awesome if I could set ignoreMissing: true but also be notified of what is missing (call a function possibly?).

Would you be interested in a PR to support this? (Or something similar?)

var options = { ignoreMissing: tellMe }
// make call to required that would normally give an error
// require('mybadfile.js', options, callback)

function tellMe(moduleName, sourceFilePath) {
  console.log('%s cannot require %s', sourceFilePath, moduleName)
}

PS I'm working on a JS watcher tool that runs an arbitrary command whenever any JS file in the dependency tree is changed, thanks for making this library it makes my code so short!

defunctzombie commented 10 years ago

I think this approach of passing a function via the ignoreMissing parameter is good. PR would be welcome.