1

Have a look at Dredd, for example, it makes the library Hooks available when you are running a script with the dreddcommand.

Command line

$ dredd [...] --hookfiles=./hooks.js

hooks.js

const hooks = require('hooks');
...

How does it work?

Victor Ferreira
  • 6,151
  • 13
  • 64
  • 120

2 Answers2

1

I'm the maintainer of Dredd. In Dredd's case it's implemented using the proxyquire library. I think rewire does similar things.

Honza Javorek
  • 8,566
  • 8
  • 47
  • 66
0

Check out npm link, which can be used to "link" together local modules as if they were a dependency visible in the node_modules directory. This can be very useful when splitting off code into a library. I'm not exactly sure what dredd is doing, but it is likely based off of the npm link paradigm.

jakemingolla
  • 1,613
  • 1
  • 10
  • 13