husudosu / mpv-remote-node

MPV Remote plugin
MIT License
47 stars 9 forks source link

Git bash on Windows breaks the script. #14

Closed VictorGamerLOL closed 1 year ago

VictorGamerLOL commented 1 year ago

Using git bash on windows makes the script return the error that it could not find the module remoteServer.js

Upon further investigating this, for some reason, when using git bash, pathsep turns into "/" instead of "\\", so the result of s[s.length - 1] = filename; would end up being "remoteServer.js" instead of the full path, and try to get this file from wherever you accessed the video file rather than your actual script path.

Later on I found out that git bash stores the windir environment variable in all caps rather than lowercase. A simple fix for this would be replacing var platform = mp.utils.getenv("windir") ? "win32" : "unix"; with var platform = mp.utils.getenv("windir") || mp.utils.getenv("WINDIR") ? "win32" : "unix";, and it worked out of the box for me. Took me a while of some odd debugging with mp.msg.info .

husudosu commented 1 year ago

You can do a PR about the fix if you'd like. I suggest using dev branch.

VictorGamerLOL commented 1 year ago

@husudosu will do after I test this on my linux installation and in powershell.

husudosu commented 1 year ago

9f621a8 PR accepted.