porsager / wright

🚀 Work Fast Work Wright
Do What The F*ck You Want To Public License
180 stars 15 forks source link

Fix for WSL path folders appearing in project dir #38

Closed JAForbes closed 5 years ago

JAForbes commented 5 years ago

What / Why

There was an issue where on WSL there would be folders in the project directory named as C:\Users\:username\.wright.

The problem arose because node running in WSL doesn't understand windows paths and treats them as filenames. Chrome however is not running in the WSL context. The solution in this branch is to generate distinct paths for usage by Node and by Chrome.

How to test

I definitely recommend manually testing this on each platform. But I've added a set of tests that at least document my assumptions about each environment.

I've also modified the utils a bit to make them easier to test. Hopefully that's ok. Static properties are now functions. process is passed in as an argument too.

To run the tests:

Questions

I use Maybe's to model the uncertain aspects of interacting with process. I also changed how the username is extracted from the path to handle non ASCII usernames. Basically replace a regex for a string split. It might be worthwhile to do that in a separate PR or not at all.