-
Notifications
You must be signed in to change notification settings - Fork 115
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
Always use forward slash on import paths #346
Conversation
_ => rel_path.to_string_lossy().into(), | ||
}; | ||
|
||
let path = if cfg!(target_os = "windows") { | ||
str_path.replace('\\', "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this is sufficient, since paths can contain \.
We might need to iterate over the path components, not sure though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this is sufficient, since paths can contain \.
Wdym? Is a component allowed to contain \
? This replaces every \
for /
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems \
is allowed in Unix file/directory names, but this shouldn't be a problem, as the replace only happens if the user's OS is Windows, where \
is not allowed in file/directory names.
I also suspect TS itself would not be very fond of a file containaing \
in its name.
It could even be a reasonable idea to throw a compile time error if #[ts(export_to)]
or TS_RS_EXPORT_DIR
contain backslashes as that would probably produce unintended behavior and destroy portability, by having a path that can't exist on Windows. Of course, doing so would be another of those "technically a breaking breaking change, but probably won't affect anyone" versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right, sorry about that!
I thought I remembered some weird rules for paths on windows, but i was mistaken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks man! especially happy about the windows CI!
Goal
This PR changes import paths such that they will always use forward slash
/
as the path separator, even on Windows. It also adds a windows test run to the CICloses #345
Changes
If
target_os = "windows"
, replace\
with/
Checklist