Fix scripts cmd slashes for windows#2082
Conversation
|
Internally, Windows actually supports both Does it fail in npm too? |
|
Ah I see, it only fails when there's a dot at the start Absolute paths work fine. I wonder if we could resolve the path before running the command. Node.js should have a built-in path method for that. |
|
Yes this actually fails for relative paths, and as mostly exec paths in scripts are relative. Yes NPM has the same the old issue. Windows users seem to have a big tolerance (which is not very good). So I think it should be fixed in a proper way. Windows people are complaining in different repos, but it is still not fixed in years.
Well node |
|
This diff is pretty complex, but the tests seem comprehensive. Let's ship it! |
|
@ctaggart - You should be able to omit the |
|
@Daniel15 Thank you! That worked great with nightly v0.20.0-20170107.0149 and the latest stable release 0.18.1. |
|
😃 By the way, npm has the same behaviour - It'll look in |
|
Btw I would recommend on windows 10 to completely migrate development process to "Ubuntu bash for windows". |

Summary
This address the issue #1729 which as about that on windows yarn fails to execute scripts that contain commands with unix-style slashes, for example this will fail on windows:
So to run such script on windows machine successfully we need to replace slashes from
/to\,For we need to find all the executable commands in the script line, so we assume that exec commands that need to be fixed:
&&or&or||or|&&or&or||or|symbols after which command go may not be inside the quotes. In opposite case this will mean that it is inside the nested command like:docker run container bash -c "cat some.thing | some/bin/here"/are replaced with windows slashes\Test plan
Added test that check correct transformation for different command cases.
So this need some triage and opinions.