-
Notifications
You must be signed in to change notification settings - Fork 247
cross-env, cross-env-shell not working on MacOS.13 #148
Comments
@kentcdodds, any thoughts on this? Am I expecting the wrong behavior? Thanks! |
Hey @brucejo75, I'm pretty sure what's happening is your shell is evaluating the value of
I think that'll work. |
Whoops, you my also need to escape the dollar sign:
|
@kentcdodds, thanks much! that worked. |
@kentcdodds, errr When I run on the command line it works. If I put it into a package.json and Attempt 1
ResultCannot handle escaped
Attempt 2: Remove escaping for
|
Hi @brucejo75, I'm afraid I don't have time to help debug this. Anyone else want to help? Please feel free to dig further by adding some console.logs in |
@kentcdodds, I got some more data. Essentially, what I found was that windows quoting and OSX (bash) quoting were exactly the opposite in terms of what worked.
I propose enabling Windows to work with Environmentnode - 8.8.1 More dataOK, a little more research. I created these rules in "greet": "npm run greet0 && npm run greet1 && npm run greet2",
"greet0": "cross-env-shell GREETING=Hi NAME=Joe echo unquoted $GREETING",
"greet1": "cross-env-shell GREETING=Hi NAME=Joe \"echo doubleQuotes $GREETING\"",
"greet2": "cross-env-shell GREETING=Hi NAME=Joe 'echo singleQuotes $GREETING'" On OSXFor OSX I also added a console.log to output the return value from commandConvert in command.js.
The only one that properly processes the On WindowsFor Windows I also added a console.log to output the return value from commandConvert in command.js.
Essentially, Windows works with all forms but using the single quotes fails it. Proposed FixIf I look at the Windows output, essentially Windows treats Then it tries to spawn I propose adding code to look at each argument to
@kentcdodds, let me know if this looks good to you and I can gin up a PR. |
Thanks for all that work @brucejo75! So, to be clear, you're saying that if someone has a script with single quotes that wont work? If that's correct, this is a known issue and has nothing to do with cross-env. People should only use double quotes for scripts if they want to support multiple platforms. Am I missing something? |
I am saying that:
I have a fix that will make single quotes work on Windows. Try it yourself: Put these rules into a package.json file with the
This is what I see:
|
Ah, I see. Ok, so of those, the only one that should work on both platforms is the double quotes one:
If you have a fix for that I'd definitely welcome it! Thank you for your patience with this! My time to work on this project is extremely limited. |
I can reproduce this issue in MacOS 10.15.2 (Catalina). So I guess something has changed since MacOS 10.13 (High Sierra). I.e, the example @brucejo75 gave:
This is what I see.
Unfortunately I cannot verify the behavior on Windows. |
Ran across this tool. Seems to be very useful in its description. But when I first ran the tool it did not act in a way that I expected. I expected running the tool in both environments to be exactly the same and they were not.
Environment
cross-env version: 5.1.0
node version: 8.7.0
npm version: 5.4.2
Windows version: 10 1703 (OS Build 15063.674)
MacOS: 10.13
Test code
I created 2 simple test scripts and ran them, one for windows the other for MacOS. Then I ran them
Windows:
cross-env-test.cmd
:MacOS:
cross-env-test.sh
Results
Windows:
MacOS:
Expected
I expected the results of both operations to be exactly the same.
Suggestion
As a verification I cloned the project on my MacOS and ran all your tests and they passed. But all of the tests were unit tests you had no full integration tests.
Recommend you add full integration tests, feel free to use the tests I supplied.
The text was updated successfully, but these errors were encountered: