How to pass an argument to 2nd command when using `concurrently` with npm?

1k views Asked by At

I have 2 npm scripts: tsc -w and jest --watch that I want to execute concurrently. I know there is a tool called concurrently that could be used for this.

"test:watch": "concurrently -P --kill-others \"npm run watch\"  \"jest --watchAll -- {@} \"",

Problem is I want to pass a param to the Jest command, and not to the concurrently command.

How to pass an argument to the 2nd command when using concurrently with npm?

1

There are 1 answers

0
Ilya Kushlianski On

Use the pass-through flag to pass arguments from your command line to the script.

"test:watch": "concurrently -P --kill-others \"npm run watch\"  \"jest --watchAll -- {@} \"",

Use it like this:

npm run test:watch -- -- cookie

You need to use -- twice to reach the inner Jest script!