Reputation: 4713
If your code detects that it is called by require
, you may want it to branch accordingly, doing or not doing certain things in each case. How do I do this?
Upvotes: 1
Views: 128
Reputation: 39395
Sure, just check if module.parent
is not null
or undefined
. If it is set with an object, then your module is being called with require
.
Upvotes: 2