-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add parameter/argument passthrough option #33
Comments
@MadLittleMods have you found any workaround for this? |
if someone has time to create a PR, I'll merge it. Sorry for the delayed response. |
If someone wants to implement this, let's do the simpler way first and think about the fancy tricks later. I don't like the |
Implemented as |
Use -- to pass through arguments to the first command. ``` concurrently "echo foo" "echo bar" -- baz ``` ``` echo foo baz echo bar ``` Use the -a or --all option to pass through the arguments to all the commands. ``` concurrently "echo foo" "echo bar" --all -- baz ``` ``` echo foo baz echo bar baz ```
My PR is an alternative implementation where the arguments are either passed to the first command (default) or all the commands (--all option). The unit test has not been tested on windows. |
Hi @thaggie and @MadLittleMods, I reviewed both PRs. However, if you have examples of programs that work similarly, we could review the need of such option. |
My use case is for |
After a little thought it might be better to default to the last command as that's the one closest to the |
So isn't it better if you directly specify those args for the process that will use it? |
Not sure what you mean. I want to be able to: and have From package.json:
|
Any news on this? My use case is the same as @thaggie |
An alternative would be use "myScript": "bash -c 'concurrently \"npm run start\" \"npm run _wait-for-server-up && npm run _run-subset-tests -- ${0} && npm run open-report\"'", So you can use like: npm run myScript -- --myArgument It's not the best solution, but could help someone while we don't have an official implementation of this feature. I read it here: npm/npm#9627 |
I created a const concurrently = require('concurrently')
const args = process.argv.slice(2).join(' ')
concurrently(
[
{ command: 'npm:dev:server', prefixColor: 'blue', name: 'server' },
{ command: 'npm:dev:client -- ' + args, prefixColor: 'magenta', name: 'client' }
],
{
killOthers: ['failure', 'success']
}
) Then I can do:
And as an npm script: "scripts": {
"dev": "node run.js",
}
|
While it's not ideal, env vars are pretty easy to use as a short term workaround: "scripts": {
"dev:support": " // some other proc here",
"test:only": "truffle test $TRUFFLE_TEST",
"test": "concurrently --kill-others --success first npm:dev:support npm:test:only"
}, Then you can run the script as: TRUFFLE_TEST=./test/MyTest.js npm test |
When using Yarn, it works! |
@Ore4444 that is not a passthrough though, you are passing - -watch to each subcommand directly in the script. |
hi, just wondering if this has been implemented or not. |
well, .,.,. This has been a while, if someone sees my post please put a link to the change implementation... |
any news on this? the env var hack is good as work-around |
The recent pr #307 looks promising. Hope to see it merged in one way or another in the near future. This would be great to have. |
You can find the documentation on the implementated passthrough functionality here. Copy of the documentation on the "All arguments" option:
|
Running
npm run dev -- --foo=bar
will result inconcurrently --raw "npm run start" "gulp watch" "--foo=bar"
which doesn't properly add the parameter to any of the commands.The double dash
--
parameter passing is part ofnpm run
so "you can use custom arguments when executing scripts", https://docs.npmjs.com/cli/run-scriptWe could add an
--parameter-passthrough
option toconcurrently
that would add the last command chunk onto each command piece. The last chunk that would be considered parameters could even be separated by--
.So running
npm run dev -- -- --foo=bar
would result in the following afternpm
,concurrently --raw "npm run start" "gulp watch" "--" "--foo=bar"
and then finallynpm run start --foo=bar && gulp watch --foo=bar
An issue is adding the extra
--
for npm run arg passing. As you can see above, for it to be effective, it would actually need to benpm run start -- --foo=bar && gulp watch --foo=bar
. Perhaps the npm script should be updated to include the extra--
though:"dev": "concurrently --raw --parameter-passthrough \"npm run start --\" \"gulp watch\""
If we wanted to get fancier could even add separation with
--0
,--1
which would go to each indexed command chunk respectively,npm run dev -- --0 --foo=bar --1 --qux=dorf
which would finally end up atnpm run start -- --foo=bar && gulp watch --qux=dorf
The text was updated successfully, but these errors were encountered: