Skip to content

when using cross-env-shell, the CLI args get split on whitespace #324

Description

@thepuzzlemaster

version: 1.14.0
platform: OSX

repro: I have the following script in my package.json

"test:integration:start": "cross-env-shell start-server-and-test \"node server.js\" https-get://localhost:3333 \"cypress run\"",

When I run yarn test:integration:start, it always splits up node and server.js and cypress and run, so it tries to launch the server using node, and then waits for a response at server.js. I've tried every combination of escaped double quotes or single quotes I can think of to get it to read those strings together, but to no avail.

  • expected behavior
    start-server-and-test can read my strings without splitting on whitespace

  • actual behavior
    Each string is split on whitespace, leading to the script incorrectly parsing the command.

I also tried pulling out the strings into environment variables, but got the same result.
I also tried putting each command into its own npm script, and while that does actually work, it runs the commands with npm rather than yarn. If I add the yarn prefix, it splits those 2 words apart as well (e.g. starts the server using yarn and then waits for a response on myScriptName.)

I'm sure this has to do with the combination of cross-env-shell with start-server-and-test, but I'm hoping there's a way around it where i can continue to use both libraries.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions