Avoid our devDependencies when requiring 'hubot' #138
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Because we have hubot in our devDependencies, if these dependencies are
installed,
require 'hubot'
will pick up the local version of hubot insteadof the one that the robot is running from. This means that our emitted
TextMessage
s won't trigger anyTextListener
s installed by scripts (sincethat uses
instanceof
).Implement a workaround that avoids loading 'hubot' from our local node_modules
folder if possible. It first tries finding 'hubot' without our node_modules,
and if that fails, it walks up the module parent tree until it finds a module
outside our directory tree and tries again from that spot. This means it works
correctly even if hubot-slack is installed with
npm link
. It falls back to anormal
require 'hubot'
if all else fails, which allows the test suite towork.
This is an alternative to PR #137.