kevinbeaty / any-promise

NOTE: You probably want native promises now
MIT License
179 stars 17 forks source link

Try to require from the main modules view point #25

Open maxnordlund opened 8 years ago

maxnordlund commented 8 years ago

This should make it more robust, since it will more closely match the applications require behaviour.

kevinbeaty commented 8 years ago

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.

kevinbeaty commented 8 years ago

In what situation would require.main.require work? I didn't really see anything documented in that regard on a quick look.

maxnordlund commented 8 years ago

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.

maxnordlund commented 8 years ago

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.

kevinbeaty commented 8 years ago

@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.

jamestalmage commented 8 years ago

Hmm. I think I would be tempted to use caller instead of main.

jamestalmage commented 8 years ago

@sindresorhus