Skip to content
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

Wildcard option doesn't seem to follow README #312

Closed
TigersWay opened this issue Apr 5, 2022 · 12 comments · Fixed by #385
Closed

Wildcard option doesn't seem to follow README #312

TigersWay opened this issue Apr 5, 2022 · 12 comments · Fixed by #385
Labels

Comments

@TigersWay
Copy link

Despite #212, it seems the wildcard option still (v7.x) doesn't get name right,

concurrently "npm:watch-*"

Equivalent to:
concurrently -n js,css,node "npm run watch-js" "npm run watch-css" "npm run watch-node"

but gives now:
concurrently -n watch-*js,watch-*css,watch-*node "npm run watch-js" "npm run watch-css" "npm run watch-node"

Something I understood wrong or a recurring bug?

@AmmarArnt
Copy link

Getting the same behaviour with 7.1.0

It seems that naming got broken.

@gustavohenke
Copy link
Member

gustavohenke commented Apr 27, 2022

#212 actually caused this bug, from what I can see.

It made the current command name the prefix for expanded commands, but it so happens that when you use the shortcut npm:/yarn: and etc, the command you're going to run becomes the command name.

In the docs case, the watch-* is the command name, which is then simply suffixed by the wildcard's contents, so it becomes watch-*js and so on.

@gustavohenke
Copy link
Member

Might be one way of fixing this.
When a command's name contains wildcards, it's replaced there too.

To make the problem more apparent, you can try running the command line concurrently -n wild-west-* "npm:watch-*".

  • Currently/before, it gets translated to concurrently -n wild-west-*js,wild-west-*css "npm run watch-js" "npm run watch-css"
  • After, it would be translated to concurrently -n wild-west-js,wild-west-css "npm run watch-js" "npm run watch-css".

Any thoughts?

@TigersWay
Copy link
Author

@gustavohenke I would love not to be the only one answering 😊 .... But i think I could use it that way!
What about then concurrently -n * "npm:watch-*"?

@gustavohenke
Copy link
Member

That's exactly what I've suggested 👍

Mind you, this change will be a breaking change as it turns * into a special character for -n.

@gkweb
Copy link

gkweb commented May 7, 2022

I'm having the same issue here. I ended up just manually inputing the commands with no wildcards.

@justmoon
Copy link

If you don't mind a little jank, you can use this as a workaround:

concurrently -n '​' 'npm:watch-*'

There is a zero-width space character being passed as the argument to -n. So this will only work if you copy/paste the above. It won't work if you try to type it in without the ZWS.

@patrickfatrick
Copy link

patrickfatrick commented Nov 8, 2022

Hi, trying out concurrently and came across this issue rather immediately because I happen to use wildcards liberally (currently using npm-run-all which also supports wildcards). passing -n is a workaround (ie concurrently -n build: \"npm:build:*\" is equivalent concurrently -n build:server,build:client \"npm:build:server\" \"npm:build:client\"). However the description in #211 is IMO not what should happen when -n is not passed. It should match the name of the script in package.json, not the wildcard contents (ie build:js not js).

Unless the readme has changed recently I don't see anything in it that indicates it should behave the way as described in #211 so my preferred fix is to simply revert #212. The example in the readme includes the -n argument.

@paescuj
Copy link
Collaborator

paescuj commented Nov 17, 2022

Since this annoys me as well, I'm going to fix it!

I think the way it is described in the README really makes sense, therefore my suggestion is to simply adjust the implementation to match this behavior:

  "scripts": {
    "lint:js": "echo js",
    "lint:ts": "echo ts",
  }
concurrently "npm:lint:*"

Will result in:

...
[js] js
[ts] ts
...

As an alternative, I think we could also just use the name of the matching script, which in that case will result in:

...
[lint:js] js
[lint:ts] ts
...

(However, with this approach the "prefixing" as described in the README would no longer make sense)

Please let me know, which solution you prefer! Thanks!

@patrickfatrick
Copy link

You're right, the readme does stipulate that behavior here

concurrently "npm:watch-*"

# Equivalent to:
concurrently -n js,css,node "npm run watch-js" "npm run watch-css" "npm run watch-node"

Personally I don't think that's really any better than showing the full script name like so

concurrently "npm:watch-*"

# Equivalent to:
concurrently -n watch-js,watch-css,watch-node "npm run watch-js" "npm run watch-css" "npm run watch-node"

However I will also say that it's easier to add the watch- prefix via -n arg than it is to remove it for users who DO only want to show the wildcard-matched string. So, either way, I guess.

@paescuj
Copy link
Collaborator

paescuj commented Nov 18, 2022

Thanks @patrickfatrick! I really appreciate your feedback on this!

I agree that both solution do come with a few drawbacks and thus realized that it might be worth starting a discussion in a separate thread to find a better solution.
However, since this issue here is valid as concurrently indeed doesn't behave like described in the README, I decided to focus on fixing this, for now.

@patrickfatrick
Copy link

@paescuj awesome, that was quick. Look forward to its release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants