i-like-robots / rewireify

Rewireify is a port of Rewire for Browserify that adds setter and getter methods to each module so that their behaviour can be modified for better unit testing.
https://www.npmjs.com/package/rewireify
Other
59 stars 10 forks source link

Slashes in windows #5

Closed chandru9279 closed 9 years ago

chandru9279 commented 10 years ago

path.join returns single backslash, if you are interpolating into a string, then they become escape sequence in windows.

I was getting error like : ERROR [framework.browserify]: Error: Cannot find module 'c:WorkReposSample-ProjectBuildScriptsGulp

Use something like https://www.npmjs.org/package/slash to normalize this on all OS.

I added a replace clause as temporary workaround for me.

path.join((__dirname), "__get__").replace(/\\/g, "/")

i-like-robots commented 10 years ago

Thanks for making a ticket. This isn't an issue I've come across before (I used to work on a Windows machine a lot) so it's pretty unexpected. I'll take a look at a fix.

chandru9279 commented 10 years ago

In the bundled file, in windows, this snippet is injected:

require("c:\Work\Repos\__get__");

because dirname gives back a string that has one backslash to separate path segments. You can verify this by doing a `console.log(dirname)` in windows Node thinks they are escape sequences. If we inject this

require("c:\\Work\\Repos\\__get__");

or this

require("c:/Work/Repos/__get__");

Then it works as expected

i-like-robots commented 10 years ago

I just realised I did this in too much of a hurry and probably isn't solving your problem. I don't have access to a Windows machine or VM at this time but I'll make sure I test when I do.

chandru9279 commented 10 years ago

Yep. the path.join undo-es your replace. It converts back to OS Native path seperator.

i-like-robots commented 9 years ago

I have a Windows VM, this will be fixed!

screen shot 2014-11-04 at 10 41 00