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

Fix some more Windows paths issues #63

Merged
merged 2 commits into from
Mar 21, 2018

Conversation

apihlaja
Copy link
Contributor

When using __filename in Browserify, I was getting mixed path separators, like /stores\MyStore.js.

When searching issues and PRs, I found that similar issue is fixed earlier. So I thought I´d apply same fix to __filename and __dirname too. But before doing anything, I ran npm test and learnt it doesnt pass in Windows. So I had to fix couple of tests too, by using path.join, to get it work.

Also, currently, PR includes appveyor.yml equivalent of your Travis config. Considering there have been quite many Windows related issues lately, it might be good idea to start using Windows based CI too.

- for Windows compability, replace '\' with '/'
- make tests to pass in Windows (use path.join for filenames)
@parshap
Copy link
Collaborator

parshap commented Nov 14, 2015

When searching issues and PRs, I found that similar issue is fixed earlier. So I thought I´d apply same fix to __filename and __dirname too. But before doing anything, I ran npm test and learnt it doesnt pass in Windows. So I had to fix couple of tests too, by using path.join, to get it work.

It looks like you're normalizing __filename and __dirname to use / on Windows. Shouldn't they use \ separators on Windows? When I console.log(__filename) on Windows I get this: C:\Users\IEUser\test.js. The other paths are normalized to use / because they are paths used by require(), which expects / paths even on Windows.

Also, currently, PR includes appveyor.yml equivalent of your Travis config. Considering there have been quite many Windows related issues lately, it might be good idea to start using Windows based CI too.

Awesome! Windows CI would be amazing. Does @substack or someone need to make an Appveyor account and enable the GitHub hook?

@apihlaja
Copy link
Contributor Author

apihlaja commented Jun 5, 2016

I remember writing reply but apparently it´s lost.

It looks like you're normalizing __filename and __dirname to use / on Windows. Shouldn't they use \ separators on Windows? When I console.log(__filename) on Windows I get this: C:\Users\IEUser\test.js.

When looking at it, the correct way to fix it would be to remove leading slash. Then the path would be what it pretends to be: relative path from project root. But doing so might break many projects. Another option would be to remove leading slash on Windows only. That would work.

In context of Browserify, normalizing to *nix format makes sense: runtime environment is "browser", not Windows or *nix. Also, path-browserify works only with /. But maybe there is some other use-cases where that doesn't work.

Awesome! Windows CI would be amazing. Does @substack or someone need to make an Appveyor account and enable the GitHub hook?

Sign-in using GH account, click new project and pick repo from the list.

@parshap
Copy link
Collaborator

parshap commented Aug 29, 2016

In context of Browserify, normalizing to *nix format makes sense: runtime environment is "browser", not Windows or *nix.

Thanks -- that makes sense. I'm 👍 for this, but don't have easy access to a Windows machine to test or enough context to feel comfortable merging it in. Will leave for another collaborator.

@brettz9
Copy link

brettz9 commented Mar 20, 2017

Windows users may also be interested in a different path issue (related to source maps) in #68

@goto-bus-stop
Copy link
Member

Just enabled appveyor; this seems to work ok, thanks! Hopefully it's still useful for you even 2½ years later :)

@goto-bus-stop goto-bus-stop merged commit 07abd48 into browserify:master Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants