Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch modules loaded via relative paths #3

Open
guiprav opened this issue Jul 5, 2013 · 3 comments
Open

Patch modules loaded via relative paths #3

guiprav opened this issue Jul 5, 2013 · 3 comments

Comments

@guiprav
Copy link
Contributor

guiprav commented Jul 5, 2013

Hi, Russ.

Is it not possible to patch modules loaded from a relative path (e.g. require('./foo') or require('../src/bar'))? If not, is there a reason for it?

Thanks.

P.S.: I tried adding a 'question' tag to this issue, but I couldn't find it. Not sure if GitHub is buggy today or if you disabled it ^_^

@devdazed
Copy link
Owner

devdazed commented Jul 5, 2013

It should be patching this, I am labeling this as a bug. I think it has to do with the way the patch module resolves.

@guiprav
Copy link
Contributor Author

guiprav commented Jul 5, 2013

Yeah, I it's probably because require.resolve will resolve relative to the calling file, which is patch.js, not the file where patch() was called from. The fix is probably as simple as detecting a relative path and prepending '../../' to it or something. If I get to fix it this weekend, I'll send you a pull request.

Thank you.

On Fri, Jul 5, 2013 at 5:45 PM, Russ Bradberry [email protected]:

It should be patching this, I am labeling this as a bug. I think it has to
do with the way the patch module resolves.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3#issuecomment-20538196
.

@guiprav
Copy link
Contributor Author

guiprav commented Jul 6, 2013

Looks like fixing that would break the API as well, haha. I just found Sinon, too. It looks awesome. Looks like it's got all the features I imagined for SuperMock plus a lot more. I'll be using it for my projects from now on. Good luck with SuperMock.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants