any-promise
any-promise copied to clipboard
Try to require from the main modules view point
This should make it more robust, since it will more closely match the applications require
behaviour.
Thanks. I haven't had a chance to really look at this, but seems like a good idea. I'll have to look at why the tests are failing though.
In what situation would require.main.require
work? I didn't really see anything documented in that regard on a quick look.
It doesn't work in the REPL, but other then that it should always work. Basically, if there's an entry point (unlike the REPL), there's an main module. E.g. node foo.js
-> foo.js
is the main module.
Regarding the tests, it may be that it tries to require from within mocha, which should be solvable by using a local copy instead of the global one.
@jamestalmage Do you have any thoughts on preferring require.main.require
for use with auto-detection of an implementation? This would apply more to any-observable
since global Promise
are more common and would be preferred.
Hmm. I think I would be tempted to use caller
instead of main
.
@sindresorhus