lerna / lerna

Lerna is a fast, modern build system for managing and publishing multiple JavaScript/TypeScript packages from the same repository.
https://lerna.js.org
MIT License
35.73k stars 2.26k forks source link

lerna run: Don't error if no scoped packages are matched #859

Closed treshugart closed 6 years ago

treshugart commented 7 years ago

I'm implementing #822 and have been attempting to integrate it into our workflow. However, I'm running into some issues where I want to scope some commands using that flag (--since) but don't want it to error if no packages are run.

In thinking about this, I'm not sure it's valuable to ever exit with non-zero if no scoped packages are matched; it doesn't seem like an exceptional state. Warning might be fine, but even then, it's fairly clear when no packages are matched.

Expected Behavior

I would expect to be able to run lerna run something --scope some-unmatched-package without errors.

This is also inconsistent with how scoping is applied to built-in Lerna commands as well as exec. For example, bootstrap and ls don't error if a filtering option doesn't match any packages, it just logs that it didn't run in any packages.

Current Behavior

The command errors. This means you can't do something like lerna run eslint --since this-branch to only lint against changed files, it will fail linting if no packages have been changed.

To work around this you can do something like lerna exec --since ref -- eslint.

Possible Solution

The built-in commands log how many packages a command was run in, so maybe we can follow suit here for run.

Steps to Reproduce (for bugs)

n/a

Context

This seems only an issue for lerna run, so to work around it you could use exec, but it feels odd to have to do something like lerna exec --scope package -- npm run test.

Your Environment

n/a

evocateur commented 7 years ago

The inconsistency between scoped ls/bootstrap and run is certainly itchy. I am open to making it more consistent.

evocateur commented 6 years ago

This was fixed waaaay back in v2.0.0 🤸‍♀️

lock[bot] commented 5 years ago

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.