mysticatea / npm-run-all

A CLI tool to run multiple npm-scripts in parallel or sequential.
MIT License
5.73k stars 239 forks source link

Glob matching does not work when specified in script using Yarn 2 #200

Open Robin-Hoodie opened 3 years ago

Robin-Hoodie commented 3 years ago

Running a script echo: run-p echo:* defined in package.json will not work on Yarn 2.

Example package.json:

{
  "name": "test-yarn1",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "echo:bar": "echo 'bar'",
    "echo:foo": "echo 'foo'",
    "echo": "run-p echo:*"
  },
  "devDependencies": {
    "npm-run-all": "^4.1.5"
  }
}

To reproduce:

=> No matches found: "echo:*"

Oddly enough, running yarn run-p echo:* directly does still work

Reproduction repo: https://github.com/Robin-Hoodie/yarn2-npm-run-all-repro

nigelzor commented 3 years ago

I just ran into this myself. If you quote the * then yarn won't try to handle the wildcard and run -p will work as expected.

Try this:

  "scripts": {
    "echo:bar": "echo 'bar'",
    "echo:foo": "echo 'foo'",
    "echo": "run-p 'echo:*'"
  }
Robin-Hoodie commented 3 years ago

Thanks for the tip, that works!

I do think the root cause of this should be fixed however (whether here or in Yarn 2) If not that, at minimum some documentation can be added

arthurfiorette commented 3 years ago

I ended up falling for that too. Please add it to the documentation

BasixKOR commented 2 years ago

I don't think this is a bug for both sides. Please don't get mad at me; I was also confused by the error. However, * is a valid shell syntax for globs, and Yarn implements a bash-like shell that presumably expands the wildcard.

It seems like expanding the wildcard is the expected behaviour of Yarn, and it doesn't look like npm-run-all can solve it either.

waptik commented 2 years ago

I just ran into this myself. If you quote the * then yarn won't try to handle the wildcard and run -p will work as expected.

Try this:

  "scripts": {
    "echo:bar": "echo 'bar'",
    "echo:foo": "echo 'foo'",
    "echo": "run-p 'echo:*'"
  }

Thanks very much for this. I had to line up all related script commands on one line as I didn't know what to do.

mathieutu commented 2 years ago

Hey, just had the issue too.

it doesn't look like npm-run-all can solve it either.

Agree, but adding it to the doc could be a good help, it avoids people to look for this issue 🙂.

BensThoughts commented 2 years ago

Ditto to all of the above. Thank goodness for github issues and threads like these. This was the first thing that broke when I updated to yarn 2, given that the docs say it will work with yarn this was a little confusing to find the solution here.

kachkaev commented 2 years ago

Adding double quotes works for me in Yarn 4.0.0-rc.27:

  "scripts": {
    "echo:bar": "echo \"bar\"",
    "echo:foo": "echo \"foo\"",
-   "echo": "npm-run-all echo:*"
+   "echo": "npm-run-all \"echo:*\""
  }

Otherwise, it says No matches found: "echo:*". Using double quotes for compatibility with cmd.exe.

Thanaen commented 12 months ago

I find it odd that this works for all the other manager packages (npm, yarn classic, pnpm, bun), but not for modern Yarn. 😅