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

Throws error when a glob pattern doesn't match any script #182

Open
OleksiyRudenko opened this issue Nov 1, 2019 · 4 comments
Open

Throws error when a glob pattern doesn't match any script #182

OleksiyRudenko opened this issue Nov 1, 2019 · 4 comments

Comments

@OleksiyRudenko
Copy link

OleksiyRudenko commented Nov 1, 2019

When package.json contains the scripts as follows

{
  "scripts" : {
    "install:sub-project": "cd ./sub-project && yarn",
    "postinstall": "run-p install:**"
  }
}

yarn install does what is expected, i.e. install:sub-project being executed.

When there are no scripts matching install:** an error is thrown: ERROR: Task not found: "install:**".

I tried a number of extglob patterns expecting that minimatch (assuming extglob is enabled) would support those. No luck.
E.g. "postinstall": "run-p install:*(**)" results in

$ run-p install:*(**)
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `run-p install:*(**)'
error Command failed with exit code 2.

Why do I need this?

install:** would install sub-projects dependencies in a monorepo. And I'd like to setup a monorepo boilerplate having no sub-projects mounted yet so that maintainers could add their sub-projects with the least hassle possible.

A possible workaround is just to add "install:void": ":", script (effectively explicit no-op shell command). Doesn't look really elegant though.

Will appreciate any suggestions on this.

@mysticatea
Copy link
Owner

/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `run-p install:*(**)'

Thank you for your report. But it looks the error that /bin/sh reported. So that error is not related to this package.

@mysticatea
Copy link
Owner

Ah, sorry.

When there are no scripts matching install:** an error is thrown: ERROR: Task not found: "install:**".

I find that this is the main part.

Yes, currently npm-run-all throws an error to recognize typo if matched script was not found.

But I can see worth to not throw.

@OleksiyRudenko
Copy link
Author

@mysticatea thank you for looking into this.

Just sharing my findings below hoping it might be of any use to you.

My expectation was that since npm-run-all uses minimatch under the hood and minimatch mentions support for extglob the problem could be solved by means of extglob patterns. Seems like this is not the case and minimatch supports only a subset of extglob. However it would be really nice to enjoy 0 or more pattern.

ESLint team decided to add an option to suppress the error when no files matching the pattern found and there is recent pending PR to resolve the issue. Adding an explicit option to suppress the error (or to fire a warning instead) might also be helpful.

@airtonix
Copy link

would be really nice to have this for monorepos.

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

No branches or pull requests

3 participants