Closed mansn closed 3 years ago
I am also facing this exact problem. You found any workaround?
@danielo515 No, not really any workaround. I mean, I use single quotes, but then the npm script won't work on Windows..
Maybe asking Windows users to switch script-shell
to powershell could work for them? I.e. by following these guidelines, and then just use single quotes.
@danielo515 @mansn How bout this pattern below? 👇
"greetDriver": "cross-env GREETING=Hi NAME=Joe npm run greet",
"greet": "npm run greet0 && npm run greet1 && npm run greet2",
"greet0": "cross-env-shell echo unquoted $GREETING $NAME",
"greet1": "cross-env-shell \"echo doubleQuotes $GREETING $NAME\"",
"greet2": "cross-env-shell 'echo singleQuotes $GREETING $NAME'"
...and then npm run greetDriver
or yarn greetDriver
should do the job. 😃✨
cross-env
version: 6.0.3node
version: 12.8.0npm
version: 6.11.3MacOS: 10.15.2 (Catalina)
Put these rules into a package.json file with the
cross-env
node module installed.npm run greet
See what gets echoed.This is what I see:
Unfortunately I cannot verify the behavior on Windows.
Problem description: This problem is pretty much the same as described in #148. The README.md example shows that you should wrap commands in (double) quotes (
"\
) if you want environment variable(s) to apply to a series of commands: https://github.com/kentcdodds/cross-env#cross-env-vs-cross-env-shell. But this example doesn't work on MacOS 10.15.2.Suggested solution: Unfortunately I haven't had the time to dig into the codebase to propose a solution, other than that "it should work with double qoutes".