Fix path handling to work with Windows and add tests for it #1361
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR makes it possible to run MathJax via node in Windows (without needing to use a unix subsystem). The main issue is, as usual, the use of
\
rather than/
in Windows path names, so we introduce a new function in thecontext
object that converts Windows (absolute) paths to unix-style paths when needed, and use this whenever__dirname
orimport.meta.url
or similar values are used. That way, the management of paths can use/
as it currently does.In addition, the
context
setup forcontext.os
now handles the situation within node as well (it used to always returnundefined
). This is done using theprocess.platform
value to make to the genericUnix
,Windows
, andMacOS
values. I wasn't sure how to treatcygwin
, but have decided to set it toWindows
, since it should not hurt to do the path adjustment there, and my understanding is that cygwin can use Windows paths, so it might be useful to do the translation anyway.The
context
tests are adjusted for the new values, and I've added several new files to handle testing Windows and to get full coverage in the tests.This resolves issue mathjax/MathJax#3439.