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
yarn run --if-present option flag to avoid exiting with a non-zero exit code when the script is undefined #6894
Comments
EDIT: I missed that @HavaH123 had mentioned npm's |
Thanks for the info about npm's |
@rally25rs Hey, I'd like to take this on! |
Hi @Tranced, are you actively working on this? If not, I'd like to give it a shot. Thanks. |
Any news on this? I'm really missing a feature like this at the moment. Would be amazing to get this in. |
As a maintainer of a monorepo with a few packages, I'm also interested in having // top-level package.json (ideal scenario)
"scripts": {
"build": "yarn workspaces run --if-present build",
// ...
"lint:tsc": "yarn workspaces run --if-present lint:tsc",
"test": "yarn workspaces run --if-present test"
}, Until // packages/×/package.json
"scripts": {
"build": "echo \"build is not configured for package \\\"×\\\", skipping.\"",
"lint:tsc": "echo \"TypeScript is not configured for package \\\"×\\\", skipping.\"",
"test": "echo \"Unit testing is not configured for package \\\"×\\\", skipping.\""
}, That's clearly redundant. After accidentally hearing about |
I'd like to pick this up - it wasn't too bad to get working locally, hope to have something reviewable soon. |
…cripts When --if-present is provided, yarn run will exit without error, even if the specified script is not defined in package.json. implement yarnpkg#6894
If --if-present is set, yarn run will complete successfully if the specified package script is not defined in pckage.json. re yarnpkg#6894
* If --if-present is set, yarn run will complete successfully if the specified package script is not defined in package.json.
Opened MR #7603 for this feature. |
Didn't see @ulentini's open MR for this, the one I produced is not much different. |
Also looking forward this. @mbpreble I'm looking at the other PR (#7159) and I think some of the feedback still applies to yours. Notably this comment:
Maybe if there's a test case for that it will have a higher change of being accepted? |
That comment seems to stand well enough on its own as being true. I agree this feature does provide a different behavior than just ignoring all errors when invoking yarn. There are a few people people asking for this. @arcanis - could you take another look and help move this toward a resolution one way or the other? |
Maybe @rally25rs could be deassigned to this issue because he doesn't seem involved anymore and maybe somebody else could be assigned? Somebody willing to do it like @mbpreble . I would really like this feature too! |
Issue still persists in March 30, 2020. Why did this issue go stale? |
Guys any update over this issue? |
|
Is there a way to benefit from this without using |
…s `yarn` does not support `if-present` argument, reference: yarnpkg/yarn#6894 (comment))
this doesn't work as advertised.
still throws edit: you have to run it like:
|
I really don't understand why it's still not implemented. This is the only problem I experiencing with yarn day by day. |
So instead we have to use a very lengthy command 😵💫 |
@arcanis why was this closed out? The foreach option you mentioned isn't a suitable alternative for what's being requested. |
It seems to be an npm functionality that is not replicated on yarn with yarnpkg/yarn#6894
Can you reopen this issue? It seems the issue is not fixed yet and the alternate suggestions wasn't resolving the issue |
Please reopen this issue/request of feature. In my case in CICD, we have an workarround:
But for interoperability between |
The argument to close this issue is quite stupid. I don't always want to run on every possible workspace. |
Do you want to request a feature or report a bug?
feature
What is the current behavior?
yarn run
does not have an option to exit with a zero code if the script run is not defined inpackage.json
.My use case is that I manage a mono-repo using yarn and lerna and I use something like
lerna exec --scope -- yarn run script-name
or runyarn run script-name
in a loop over all the packages.This is fragile because it breaks if any of the packages dont have the
script-name
defined.What is the expected behavior?
Similar to npm, provide a --if-present option that exits with a zero code if the script is undefined.
yarn run --if-defined script-name
Please mention your node.js, yarn and operating system version.
The text was updated successfully, but these errors were encountered: